jsm-exceptions
Version:
A comprehensive TypeScript exception library with HTTP status code support, detailed JSDoc documentation, and backward compatibility. Provides structured error handling for web applications and APIs.
39 lines (38 loc) • 1.38 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const base_exception_1 = __importDefault(require("./base.exception"));
/**
* @fileoverview Service Unavailable exception (HTTP 503)
* @author dr. Salmi <reevosolutions@gmail.com>
*/
/**
* Exception thrown when a service is temporarily unavailable.
* Corresponds to HTTP 503 Service Unavailable status code.
*
* @class ServiceUnavailableException
* @extends {BaseException}
* @example
* ```typescript
* throw new ServiceUnavailableException('Database temporarily unavailable');
* throw new ServiceUnavailableException('Service under maintenance', {
* estimatedDowntime: '2 hours',
* retryAfter: 7200
* });
* ```
*/
class ServiceUnavailableException extends base_exception_1.default {
/**
* Creates an instance of ServiceUnavailableException.
*
* @param {string} [message='Service Unavailable'] - The error message
* @param {Record<string, any>} [context] - Additional context about the service unavailability
* @memberof ServiceUnavailableException
*/
constructor(message = 'Service Unavailable', context) {
super(message, 503, context);
}
}
exports.default = ServiceUnavailableException;