Files
klz-cables.com/.pnpm-store/v10/files/58/db2bef7092349e7a418979c7d4d19265726c43a3ddd3d284ddac04ecbbf6e01e62a2bb50cc20670f4b69a7f3de7181041db5937c9b290037f61d30b81cfa9c
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

44 lines
1.6 KiB
Plaintext

import { extendError } from "./extend-error";
import { normalizeArgs, normalizeOptions } from "./normalize";
import { toJSON as errorToJSON } from "./to-json";
const constructor = Ono;
export { constructor as Ono };
/**
* Creates an `Ono` instance for a specifc error type.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
function Ono(ErrorConstructor, options) {
options = normalizeOptions(options);
function ono(...args) {
let { originalError, props, message } = normalizeArgs(args, options);
// Create a new error of the specified type
let newError = new ErrorConstructor(message);
// Extend the error with the properties of the original error and the `props` object
return extendError(newError, originalError, props);
}
ono[Symbol.species] = ErrorConstructor;
return ono;
}
/**
* Returns an object containing all properties of the given Error object,
* which can be used with `JSON.stringify()`.
*/
Ono.toJSON = function toJSON(error) {
return errorToJSON.call(error);
};
/**
* Extends the given Error object with enhanced Ono functionality, such as nested stack traces,
* additional properties, and improved support for `JSON.stringify()`.
*/
Ono.extend = function extend(error, originalError, props) {
if (props || originalError instanceof Error) {
return extendError(error, originalError, props);
}
else if (originalError) {
return extendError(error, undefined, originalError);
}
else {
return extendError(error);
}
};
//# sourceMappingURL=constructor.js.map