Skip to content

Commit

Permalink
errors/Report -- has entries
Browse files Browse the repository at this point in the history
  • Loading branch information
xieyuheng committed Aug 4, 2023
1 parent 6286343 commit f73a386
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
12 changes: 6 additions & 6 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# error report

`errors/Report` -- has `entries`

- `report.add(entry)`
- `report.format()`
- `ReportEntry` -- has `message` `span` `text`

`formatWord`

`cut` throw `Report`

`report.add(entry)`

`report.format()`

`ReportEntry` -- has `message` `span` `text`

`RunCommand` catch `report` and call `format`

# type
Expand Down
5 changes: 0 additions & 5 deletions src/lang/errors/InternalError.ts

This file was deleted.

15 changes: 15 additions & 0 deletions src/lang/errors/Report.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Span } from "../span"

export type ReportEntry = {
message: string
span: Span
text: string
}

export class Report extends Error {
entries: Array<ReportEntry> = []

constructor(message: string) {
super(message)
}
}
2 changes: 1 addition & 1 deletion src/lang/errors/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./InternalError"
export * from "./ParsingError"
export * from "./Report"
5 changes: 1 addition & 4 deletions src/lang/run/releaseFreePorts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { InternalError } from "../errors"
import { Node } from "../graph/Node"
import { Net } from "../net"
import { disconnect } from "../net/disconnect"
Expand All @@ -15,9 +14,7 @@ export function releaseFreePorts(net: Net, closer: Node | undefined): void {
}

if (port.connection === undefined) {
throw new InternalError(
`[releaseFreePorts] I expect port to have connection.`,
)
throw new Error(`[releaseFreePorts] I expect port to have connection.`)
}

net.ports.push(port.connection.port)
Expand Down

0 comments on commit f73a386

Please sign in to comment.