Skip to content

Commit

Permalink
fix: catch ECE internal error
Browse files Browse the repository at this point in the history
  • Loading branch information
shenyih0ng committed Apr 15, 2024
1 parent c39dedd commit 2137c33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/go-slang/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,16 @@ export class OutOfMemoryError extends RuntimeSourceError {
return 'runtime: out of memory'
}
}

export class InternalError extends RuntimeSourceError {
private message: string

constructor(message: string) {
super()
this.message = message
}

public explain() {
return `internal error: ${this.message}\nPlease report this issue.`
}
}
5 changes: 4 additions & 1 deletion src/go-slang/goroutine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
AssignmentOperationError,
FuncArityError,
GoExprMustBeFunctionCallError,
InternalError,
InvalidOperationError,
UndefinedError,
UnknownInstructionError
Expand Down Expand Up @@ -146,7 +147,9 @@ export class GoRoutine {
return nextState
} catch (error) {
this.state = GoRoutineState.Exited
return Result.fail(error)
return Result.fail(
error instanceof RuntimeSourceError ? error : new InternalError(error.message)
)
}
}
}
Expand Down

0 comments on commit 2137c33

Please sign in to comment.