error.js 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
/*
Classes for exceptions
Note: All exceptions thrown by Node.js or the JavaScript runtime will be instances of Error.
https://nodejs.org/api/errors.html#errors_exceptions_vs_errors

*/

class TDError extends Error {
  constructor(args) {
    super(args)
    this.name = "TDError";
  }
}
class Warning extends Error {
  // Exception raised for important warnings like data truncations while inserting.
  constructor(args) {
    super(args)
    this.name = "Warning";
  }
}
class InterfaceError extends TDError {
  // Exception raised for errors that are related to the database interface rather than the database itself.
  constructor(args) {
    super(args)
    this.name = "TDError.InterfaceError";
  }
}
class DatabaseError extends TDError {
  // Exception raised for errors that are related to the database.
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError";
  }
}
class DataError extends DatabaseError {
  // Exception raised for errors that are due to problems with the processed data like division by zero, numeric value out of range.
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError.DataError";
  }
}
class OperationalError extends DatabaseError {
  // Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError.OperationalError";
  }
}
class IntegrityError extends DatabaseError {
  // Exception raised when the relational integrity of the database is affected.
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError.IntegrityError";
  }
}
class InternalError extends DatabaseError {
  // Exception raised when the database encounters an internal error.
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError.InternalError";
  }
}
class ProgrammingError extends DatabaseError {
  // Exception raised for programming errors.
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError.ProgrammingError";
  }
}
class NotSupportedError extends DatabaseError {
  // Exception raised in case a method or database API was used which is not supported by the database.
  constructor(args) {
    super(args)
    this.name = "TDError.DatabaseError.NotSupportedError";
  }
}

module.exports = {
  TDError, Warning, InterfaceError, DatabaseError, DataError, OperationalError, IntegrityError, InternalError, ProgrammingError, NotSupportedError
};