Skip to content
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

Can we provide a friendlier default handler for unhandled exceptions? #3418

Closed
keynmol opened this issue Aug 5, 2023 · 1 comment · Fixed by #3423
Closed

Can we provide a friendlier default handler for unhandled exceptions? #3418

keynmol opened this issue Aug 5, 2023 · 1 comment · Fixed by #3423

Comments

@keynmol
Copy link
Contributor

keynmol commented Aug 5, 2023

Seems like if you have an exception thrown while rendering another exception, you get a pretty scary C++ ABI error.

Consider this:

case class MyErr(msg: String) extends Exception:
  override def toString() = msg(0) + "!"

@main def hello = 
  throw MyErr("")

See the difference between JVM and Native:

$ scli run .
Exception in thread "main"
Exception: java.lang.StringIndexOutOfBoundsException thrown from the UncaughtExceptionHandler in thread "main"

$ scli run . --native
libc++abi: terminating due to uncaught exception of type scalanative::ExceptionWrapper: std::exception
fish: Job 1, 'scala-cli $argv' terminated by signal SIGABRT (Abort)

Note how there's at least some clue in JVM version as to what the original exception was

@WojciechMazur
Copy link
Contributor

For the 0.5.x series we should be able to use default Thread.uncoughtExceptionHandler, which later can be also customized. I'll try to adjust the generated main to allow for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants