15815213711
2024-08-26 67b8b6731811983447e053d4396b3708c14dfe3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("util");
const cliTruncate = require("cli-truncate");
/** Signals that the given text cannot be fully encoded in the chosen {@link StringEncoding}. */
class NotRepresentableError extends Error {
    constructor(text, encoding) {
        super(`Not fully representable in ${encoding}:\n${util_1.inspect(typeof text === "string" ? cliTruncate(text, 65) : text)}`);
    }
}
exports.NotRepresentableError = NotRepresentableError;
NotRepresentableError.prototype.name = NotRepresentableError.name;
/**
 * Signals that the given encoded text is not valid in the chosen {@link StringEncoding}.
 *
 * @remarks
 * Not all {@link StringEncoding}s can throw this error. Most single-byte encodings and some multi-byte encodings have a valid mapping for every possible sequence of bytes. However, some encodings (such as ASCII and UTF-8) don't consider all byte sequences valid; such encodings will throw this error if the input contains any invalid byte sequences.
 */
class InvalidEncodedTextError extends Error {
    constructor(text, encoding) {
        super(`Input is not valid ${encoding}:\n${util_1.inspect(text)}`);
    }
}
exports.InvalidEncodedTextError = InvalidEncodedTextError;
InvalidEncodedTextError.prototype.name = InvalidEncodedTextError.name;
const specifierKinds = [
    "CFStringEncoding",
    "IANA charset name",
    "Windows codepage",
    "NSStringEncoding"
];
/** Signals that the given {@link StringEncoding} specifier (IANA character set name, `CFStringEncoding` constant, or the like) is not recognized or not supported. */
class UnrecognizedEncodingError extends Error {
    constructor(encodingSpecifier, specifierKind) {
        if (typeof specifierKind !== "string")
            specifierKind = specifierKinds[specifierKind];
        super(`Unrecognized ${specifierKind}: ${util_1.inspect(encodingSpecifier)}`);
    }
}
exports.UnrecognizedEncodingError = UnrecognizedEncodingError;
UnrecognizedEncodingError.prototype.name = UnrecognizedEncodingError.name;
//# sourceMappingURL=errors.js.map