diff --git a/TODO.md b/TODO.md index 9791b16..09387b8 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ -[lang1] `load` -- use `Report` instead of `LangError` -[lang0] `load` -- use `Report` instead of `LangError` -[lang1] `Lang1Command` -- catch `Report` -[lang0] `Lang0Command` -- catch `Report` +[lang0] remove `ErrorReport` + [lang0] add snapshot test for error report # lang1 @@ -12,6 +10,7 @@ # docs +[docs/lang0] simple readme like inet [docs/lang0] 用中文重新整理 lambda encoding 相关的知识。 [docs/lang0] 用中文重新整理 lambda encoding 和 self type 相关的知识。 diff --git a/src/command-line/commands/Lang1Command.ts b/src/command-line/commands/Lang1Command.ts index 2599cda..24a2a44 100644 --- a/src/command-line/commands/Lang1Command.ts +++ b/src/command-line/commands/Lang1Command.ts @@ -33,8 +33,12 @@ export class Lang1Command extends Command { try { await run(url) } catch (error) { - console.error(error) - process.exit(1) + if (error instanceof Error) { + console.error(error.message) + process.exit(1) + } + + throw error } } } diff --git a/src/lang1/errors/ErrorReport.ts b/src/lang1/errors/ErrorReport.ts deleted file mode 100644 index c1e06e0..0000000 --- a/src/lang1/errors/ErrorReport.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { LangError } from "./LangError.js" - -export class ErrorReport extends LangError { - constructor(public message: string) { - super(message) - } -} diff --git a/src/lang1/errors/index.ts b/src/lang1/errors/index.ts index 0c64caa..7a58de4 100644 --- a/src/lang1/errors/index.ts +++ b/src/lang1/errors/index.ts @@ -1,2 +1 @@ -export * from "./ErrorReport.js" export * from "./LangError.js" diff --git a/src/lang1/run/load.ts b/src/lang1/run/load.ts index 87108b6..b17b699 100644 --- a/src/lang1/run/load.ts +++ b/src/lang1/run/load.ts @@ -1,7 +1,6 @@ import { Fetcher } from "@cicada-lang/framework/lib/fetcher/index.js" import { ParsingError } from "@cicada-lang/sexp" import fs from "node:fs" -import * as Errors from "../errors/index.js" import { createMod, type Mod } from "../mod/index.js" import { type Stmt } from "../stmt/index.js" import { Parser } from "../syntax/index.js" @@ -36,7 +35,7 @@ export async function load( return mod } catch (error) { if (error instanceof ParsingError) { - throw new Errors.ErrorReport(error.report(text)) + throw new Error(error.report(text)) } throw error