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

Nested/chained error API #36

Closed
ArtDu opened this issue Jul 21, 2021 · 3 comments
Closed

Nested/chained error API #36

ArtDu opened this issue Jul 21, 2021 · 3 comments
Labels
feature A new functionality

Comments

@ArtDu
Copy link

ArtDu commented Jul 21, 2021

Reason

For a better understanding of where the error occurred, it is desirable to have some kind of interface where you could get a nested error. A specific example of use can be found here tarantool/crud#186.

It will be inconvenient to catch errors if there is a high level of nesting. For example (vshard -> crud -> cartridge-java -> client-app) each of these api can throw an error, catch it and generate a new one, so it will be difficult to find out what the original error was.

Examples from other languages

The functionality of nested/chained errors is implemented in other languages:

  1. Java
catch(IOException e) {
  throw new ApplicationException("Failed on reading file soandso", e);
  //                              ^ Message                        ^ Cause
}
...
// then when we catch error, we can get cause
catch(ApplicationException e) {
  e.getCause()
  ...
}
  1. Python 3
try:
    v = {}['a']
except KeyError as e:
    raise ValueError('failed') from e

# then when we catch error, we can get cause
except ValueError as e:
    e.__cause__
@olegrok
Copy link
Contributor

olegrok commented Jul 26, 2021

Perhaps this is the time for advertising.

Because Tarantool core since 2.4 support something similar.

tarantool> e = box.error.new('MyErrorType', 'Message')
---
...

tarantool> error(e)
---
- error: Message
...

tarantool> e.type
---
- MyErrorType
...

tarantool> e.trace
---
- - file: '[string "e = box.error.new(''MyErrorType'', ''Message'')"]'
    line: 1
...

Also such errors could be stacked:

tarantool> reason = box.error.new('MyErrorType', 'Reason')
---
...

tarantool> e:set_prev(reason)
---
...

tarantool> e.prev
---
- Reason
...

tarantool> e.prev.prev
---
- null
...

@kyukhin kyukhin added feature A new functionality teamS Scaling labels Aug 5, 2021
@kyukhin kyukhin added this to the wishlist milestone Aug 19, 2021
@filonenko-mikhail filonenko-mikhail added teamX and removed teamS Scaling labels Jan 17, 2022
@filonenko-mikhail filonenko-mikhail removed this from the wishlist milestone Nov 22, 2022
@kyukhin
Copy link

kyukhin commented Mar 24, 2023

Not planned.

@kyukhin kyukhin closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2023
@Totktonada
Copy link
Member

From the triage meeting: there are some plans to dramatically improve error framework in tarantool. @unera knows more.

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

No branches or pull requests

5 participants