Skip to content

Commit

Permalink
[lang1] remove ErrorReport
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Mar 28, 2024
1 parent 2523fa9 commit 25a0263
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
7 changes: 3 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,6 +10,7 @@

# docs

[docs/lang0] simple readme like inet
[docs/lang0] 用中文重新整理 lambda encoding 相关的知识。
[docs/lang0] 用中文重新整理 lambda encoding 和 self type 相关的知识。

Expand Down
8 changes: 6 additions & 2 deletions src/command-line/commands/Lang1Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@ export class Lang1Command extends Command<Args, Opts> {
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
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/lang1/errors/ErrorReport.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lang1/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from "./ErrorReport.js"
export * from "./LangError.js"
3 changes: 1 addition & 2 deletions src/lang1/run/load.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 25a0263

Please sign in to comment.