INNER CODE UNIT · TypeScript

IoError

x-cmd/x-cmd · mod/ajv/lib/ajv.ts:66

class IoError extends Error {
    readonly path: string;
    readonly code?: string;
    constructor(path: string, cause: unknown) {
        const m = cause instanceof Error ? cause.message : String(cause);
        super(m);
        this.name = "IoError";
        this.path = path;
        if (cause instanceof Error && "code" in cause) {
            this.code = String((cause as { code: unknown }).code);
        }
    }
}

// Read a data file.  Throws IoError if the file can't be read, or
// ParseError if the format-specific parser rejects the content.
async function readJson<T = unknown>(p: string): Promise<T> {
    let text: string;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…