@ayonli/jsext
Version:
A JavaScript extension package for building strong and modern applications.
97 lines (93 loc) • 3.1 kB
JavaScript
;
var error_Exception = require('./Exception.js');
/**
* This module includes some common errors that can be used in the application.
* @module
*/
/**
* This error indicates that the requested operation, such as modifying a file,
* is not allowed by the current user.
*
* NOTE: This error has an HTTP-compatible code of `403`.
*/
class NotAllowedError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "NotAllowedError", code: 403 });
}
}
/**
* This error indicates that the requested resource, such as a file, is not
* found.
*
* NOTE: This error has an HTTP-compatible code of `404`.
*/
class NotFoundError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "NotFoundError", code: 404 });
}
}
/**
* This error indicates that the target resource path, such as a file, already
* exists.
*
* NOTE: This error has an HTTP-compatible code of `409`.
*/
class AlreadyExistsError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "AlreadyExistsError", code: 409 });
}
}
/**
* This error indicates that the requested function or feature is not supported
* by the current environment.
*
* NOTE: This error has an HTTP-compatible code of `405`.
*/
class NotSupportedError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "NotSupportedError", code: 405 });
}
}
/**
* This error indicates that the requested operation, such as a function, is not
* implemented.
*
* NOTE: This error has an HTTP-compatible code of `501`.
*
* NOTE: `NotImplementedError` should only be used for stubs or placeholders,
* it should not be used to indicate the lack of support for a feature, in such
* cases, use {@link NotSupportedError} instead.
*/
class NotImplementedError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "NotImplementedError", code: 501 });
}
}
/**
* This error indicates that the requested operation, such as a network request,
* is timed out.
*
* NOTE: This error has an HTTP-compatible code of `408`.
*/
class TimeoutError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "TimeoutError", code: 408 });
}
}
/**
* This error indicates that the connection between the client and the server
* cannot be established.
*/
class NetworkError extends error_Exception.default {
constructor(message, options = {}) {
super(message, { ...options, name: "NetworkError" });
}
}
exports.AlreadyExistsError = AlreadyExistsError;
exports.NetworkError = NetworkError;
exports.NotAllowedError = NotAllowedError;
exports.NotFoundError = NotFoundError;
exports.NotImplementedError = NotImplementedError;
exports.NotSupportedError = NotSupportedError;
exports.TimeoutError = TimeoutError;
//# sourceMappingURL=common.js.map