hypertune
Version:
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt
24 lines • 792 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = asError;
function asError(value) {
if (value instanceof Error) {
return value;
}
if (typeof value === "string") {
return new Error(value);
}
try {
const stringified = JSON.stringify(value);
if (typeof stringified !== "string") {
// Can happen in some edge cases, e.g. JSON.stringify(() => {})
return new Error("Error that stringified to non-string value.");
}
return new Error(stringified);
}
catch (error) {
// Indicates value was non-stringifyable, e.g. recursive object, BigInt
return new Error("Error that couldn't be stringified.");
}
}
//# sourceMappingURL=asError.js.map