@sonatel-os/juf
Version:
The community SDK for Orange Money, SMS, Email & Sonatel APIs on the Orange Developer Platform.
77 lines (75 loc) • 2.71 kB
TypeScript
/**
* @class JufError
* @extends Error
* @classdesc Base error class for all JUF errors.
* Provides a consistent error response shape across the library.
*
* @example
* throw new JufError('Something went wrong', 500, 'JUF_INTERNAL_ERROR');
*/
declare class JufError extends Error {
/**
* @param {string} message - Human-readable error message.
* @param {number} [status=500] - HTTP-equivalent status code.
* @param {string} [code='JUF_ERROR'] - Machine-readable error code.
* @param {*} [details=null] - Additional error context.
*/
constructor(message: string, status?: number | undefined, code?: string | undefined, details?: any);
/** @type {number} */
status: number;
/** @type {string} */
code: string;
/** @type {*} */
details: any;
/**
* Returns a consistent JSON-serializable error response.
* @returns {{ success: false, error: { code: string, message: string, details: * } }}
*/
toJSON(): {
success: false;
error: {
code: string;
message: string;
details: any;
};
};
}
/**
* @class ValidationError
* @extends JufError
* @classdesc Thrown when input validation fails (Superstruct assertions, URL checks, etc.).
*/
declare class ValidationError extends JufError {
/**
* @param {string} message - Description of the validation failure.
* @param {*} [details=null] - Field-level details about what failed.
*/
constructor(message: string, details?: any);
}
/**
* @class AuthenticationError
* @extends JufError
* @classdesc Thrown when authentication with the Apigee platform fails.
*/
declare class AuthenticationError extends JufError {
/**
* @param {string} [message='Authentication failed. Check your credentials and try again.'] - Error message.
* @param {*} [details=null] - API response details.
*/
constructor(message?: string | undefined, details?: any);
}
/**
* @class ExternalServiceError
* @extends JufError
* @classdesc Thrown when an external API call (Apigee, payment gateway, etc.) fails.
*/
declare class ExternalServiceError extends JufError {
/**
* @param {string} message - Description of the service failure.
* @param {number} [status=502] - HTTP status from the upstream service.
* @param {*} [details=null] - Upstream response body or error details.
*/
constructor(message: string, status?: number | undefined, details?: any);
}
declare function fromAxiosError(error: object, fallbackMessage: string): ExternalServiceError;
export { AuthenticationError as A, ExternalServiceError as E, JufError as J, ValidationError as V, fromAxiosError as f };