Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(reporting): adds a new reporter: reportErrors. This is a reporti…
…ng hook that will be invoked for each error that is thrown, both when evaluating a result, and for subsequent invocations on, for example, returned function instances. Holds a reference to the error, as well ast the AST node that threw or caused the Error
- Loading branch information
Showing
16 changed files
with
124 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/interpreter/evaluator/node-evaluator/i-create-node-evaluator-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/interpreter/lexical-environment/i-set-in-lexical-environment-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import {Node} from "typescript"; | ||
import {Literal} from "../literal/literal"; | ||
import {LexicalEnvironment} from "./lexical-environment"; | ||
import {ReportingOptions} from "../reporting/i-reporting-options"; | ||
import {ReportingOptionsSanitized} from "../reporting/i-reporting-options"; | ||
|
||
export interface ISetInLexicalEnvironmentOptions { | ||
env: LexicalEnvironment; | ||
path: string; | ||
value: Literal; | ||
reporting: ReportingOptions; | ||
reporting: ReportingOptionsSanitized; | ||
node: Node; | ||
newBinding?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type ReportedErrorSet = WeakSet<Error>; | ||
|
||
/** | ||
* Creates and returns a Set of Errors that has been seen and has been reported | ||
* @returns {WeakSet<Error>} | ||
*/ | ||
export function createReportedErrorSet (): ReportedErrorSet { | ||
return new WeakSet<Error>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Node} from "typescript"; | ||
import {ReportingOptionsSanitized} from "../../reporting/i-reporting-options"; | ||
import {EvaluationError} from "../../error/evaluation-error/evaluation-error"; | ||
|
||
/** | ||
* Reports an error | ||
* @param {ReportingOptionsSanitized} reporting | ||
* @param {Error} error | ||
* @param {Node} node | ||
*/ | ||
export function reportError (reporting: ReportingOptionsSanitized, error: Error, node: Node): void { | ||
// Report the error if a reporter is hooked up | ||
if (reporting.reportErrors != null && !reporting.reportedErrorSet.has(error)) { | ||
reporting.reportedErrorSet.add(error); | ||
reporting.reportErrors({ | ||
error: error, | ||
node: error instanceof EvaluationError | ||
? error.node | ||
: node | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const TRY_SYMBOL = "[try]"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters