UNPKG

tupleson

Version:

A hackable JSON serializer/deserializer

71 lines 2.52 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var asyncErrors_exports = {}; __export(asyncErrors_exports, { TsonAbortError: () => TsonAbortError, TsonPromiseRejectionError: () => TsonPromiseRejectionError, TsonStreamInterruptedError: () => TsonStreamInterruptedError }); module.exports = __toCommonJS(asyncErrors_exports); var import_errors = require("../errors.js"); var import_isPlainObject = require("../internals/isPlainObject.js"); function getErrorMessageFromUnknown(unknown) { if (typeof unknown === "string") { return unknown; } if (unknown instanceof Error) { return unknown.message; } if ((0, import_isPlainObject.isPlainObject)(unknown) && typeof unknown["message"] === "string") { return unknown["message"]; } return null; } class TsonPromiseRejectionError extends import_errors.TsonError { constructor(cause) { const message = getErrorMessageFromUnknown(cause) ?? "Promise rejected"; super(message, { cause }); this.name = "TsonPromiseRejectionError"; } static from(cause) { return cause instanceof Error ? cause : new TsonPromiseRejectionError(cause); } } class TsonStreamInterruptedError extends import_errors.TsonError { constructor(cause) { super( "Stream interrupted: " + (getErrorMessageFromUnknown(cause) ?? "unknown reason"), { cause } ); this.name = "TsonStreamInterruptedError"; } } class TsonAbortError extends import_errors.TsonError { constructor(cause) { super("The user aborted a request.", { cause }); this.name = "TsonAbortError"; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { TsonAbortError, TsonPromiseRejectionError, TsonStreamInterruptedError }); //# sourceMappingURL=asyncErrors.js.map