smart-track
Version:
A TypeScript SDK for integrating with tracking services using the Beckn protocol. Provides adapters for package tracking with built-in error handling, retry logic, and type safety.
42 lines • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuthenticationError = exports.ValidationError = exports.NetworkError = exports.TimeoutError = exports.AdapterError = void 0;
class AdapterError extends Error {
constructor(message, status = 0, response, isRetryable = false) {
super(message);
this.name = "AdapterError";
this.status = status;
this.response = response;
this.isRetryable = isRetryable;
}
}
exports.AdapterError = AdapterError;
class TimeoutError extends AdapterError {
constructor(timeout) {
super(`Request timeout after ${timeout}ms`, 408, null, true);
this.name = "TimeoutError";
}
}
exports.TimeoutError = TimeoutError;
class NetworkError extends AdapterError {
constructor(message, originalError) {
super(message, 0, originalError, true);
this.name = "NetworkError";
}
}
exports.NetworkError = NetworkError;
class ValidationError extends AdapterError {
constructor(message, errors) {
super(message, 422, errors, false);
this.name = "ValidationError";
}
}
exports.ValidationError = ValidationError;
class AuthenticationError extends AdapterError {
constructor(message = "Authentication failed") {
super(message, 401, null, false);
this.name = "AuthenticationError";
}
}
exports.AuthenticationError = AuthenticationError;
//# sourceMappingURL=error.js.map