Skip to content

Make builtin function error on native report line number #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function runInContext(
value: sandboxedEval(transpiled)
} as Result)
} catch (error) {
if (error instanceof RuntimeSourceError) {
if (error instanceof RuntimeSourceError || error instanceof ExceptionError) {
context.errors.push(error)
return resolvedErrorPromise
}
Expand Down
7 changes: 4 additions & 3 deletions src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,10 @@ export function* apply(
break
} catch (e) {
// Recover from exception
const globalEnvironment =
context.runtime.environments[context.runtime.environments.length - 1]
context.runtime.environments = [globalEnvironment]
context.runtime.environments = context.runtime.environments.slice(
-context.numberOfOuterEnvironments
)

const loc = node ? node.loc! : constants.UNKNOWN_LOCATION
if (!(e instanceof errors.RuntimeSourceError)) {
// The error could've arisen when the builtin called a source function which errored.
Expand Down
Loading