@silane/datetime
Version:
Date and time library similar to Python's "datetime" package.
57 lines (56 loc) • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ValueDateTimeError = exports.TypeDateTimeError = exports.NotImplementedDateTimeError = exports.DateTimeError = void 0;
/**
* The base class of the other exceptions in this module.
* It is a subclass of Error.
*/
class DateTimeError extends Error {
/**
* @param {string} message Some error message.
*/
constructor(message) {
super(message);
Object.defineProperty(this, 'name', {
configurable: true,
enumerable: false,
value: this.constructor.name,
writable: true
});
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
}
}
}
/**
* Raised when derived classes should override the method.
*/
exports.DateTimeError = DateTimeError;
class NotImplementedDateTimeError extends DateTimeError {
constructor() {
super("Not implemented.");
}
}
/**
* Raised when an operation or function is applied to an object of
* inappropriate type.
*/
exports.NotImplementedDateTimeError = NotImplementedDateTimeError;
class TypeDateTimeError extends DateTimeError {
constructor(message = 'Type error.') {
super(message);
}
}
/**
* Raised when an operation or function receives an argument that has the
* right type but an inappropriate value.
*/
exports.TypeDateTimeError = TypeDateTimeError;
class ValueDateTimeError extends DateTimeError {
constructor(message = 'Value error.') {
super(message);
}
}
exports.ValueDateTimeError = ValueDateTimeError;