feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint - Remove old attempt at Reynolds Integration in favor of new library.
This commit is contained in:
@@ -1,48 +1,11 @@
|
||||
/**
|
||||
* @file rr-error.js
|
||||
* @description Custom error types for the Reynolds & Reynolds (Rome) integration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base RR API Error class — always structured with a message and a code.
|
||||
*/
|
||||
class RrApiError extends Error {
|
||||
/**
|
||||
* @param {string} message - Human-readable message
|
||||
* @param {string} [code="RR_ERROR"] - Short machine-readable error code
|
||||
* @param {Object} [details] - Optional structured metadata
|
||||
*/
|
||||
constructor(message, code = "RR_ERROR", details = {}) {
|
||||
constructor(message, code, meta) {
|
||||
super(message);
|
||||
this.name = "RrApiError";
|
||||
this.code = code;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return {
|
||||
name: this.name,
|
||||
code: this.code,
|
||||
message: this.message,
|
||||
details: this.details
|
||||
};
|
||||
this.code = code || "RR_API_ERROR";
|
||||
if (meta) this.meta = meta;
|
||||
Error.captureStackTrace?.(this, RrApiError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to normalize thrown errors into a consistent RrApiError instance.
|
||||
*/
|
||||
function toRrError(err, defaultCode = "RR_ERROR") {
|
||||
if (!err) return new RrApiError("Unknown RR error", defaultCode);
|
||||
if (err instanceof RrApiError) return err;
|
||||
if (typeof err === "string") return new RrApiError(err, defaultCode);
|
||||
const msg = err.message || "Unspecified RR error";
|
||||
const code = err.code || defaultCode;
|
||||
const details = err.details || {};
|
||||
return new RrApiError(msg, code, details);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
RrApiError,
|
||||
toRrError
|
||||
};
|
||||
module.exports = { RrApiError };
|
||||
|
||||
Reference in New Issue
Block a user