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

Capture stack trace when an error is raised #274

Open
myzie opened this issue Sep 27, 2024 · 3 comments
Open

Capture stack trace when an error is raised #274

myzie opened this issue Sep 27, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@myzie
Copy link
Collaborator

myzie commented Sep 27, 2024

Something like this should be able to show the traceback tied to a given error:

try(
  func() {
    error("kaboom")
  },
  func(err) {
    print(err.traceback())
  }
)
@myzie myzie added the enhancement New feature or request label Sep 27, 2024
@dnbsd
Copy link

dnbsd commented Oct 13, 2024

Is err in your example going to hold an error message as well? For instance I have the following script:

try (func(){
    os.chdir("/notexist")
}, "some error")

The error produced by os.chdir is out of reach and try prevents the error string being shown on stdout, therefore both a programmer and a user has no idea what went wrong.

@rubiojr
Copy link
Contributor

rubiojr commented Oct 13, 2024

@dnbsd I think that's already the case as of #265 (unreleased):

try (func(){
    os.chdir("/notexist")
}, func(err) {
  print(err)
})
➜ risor test.risor
chdir /notexist: no such file or directory

@dnbsd
Copy link

dnbsd commented Oct 14, 2024

@dnbsd I think that's already the case as of #265 (unreleased):

try (func(){
    os.chdir("/notexist")
}, func(err) {
  print(err)
})
➜ risor test.risor
chdir /notexist: no such file or directory

@rubiojr thanks, rebuilding the binary from the main branch worked.

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

No branches or pull requests

3 participants