Provide typed exceptions (java bindings)
See original GitHub issueWhat is the problem you want to solve?
A lot of extra code is written to wrap the StatusRuntimeException with named/typed exceptions for the ledger api call response.
What is the solution you would propose?
Provide typed exceptions that provide easy understanding of the business error occurring
Example:
- Create a User but the user already exists: throw a
UserExistsException
with cause: StatusRuntimeException. - Get User but user does not exist: throw a
UserNotFoundException
with cause: StatusRuntimeException. - Get Contract but does not exist: throw
ContractNotFoundException
with cause: StatusRuntimeException.
etc etc
Yes we can inspect the status codes and contents of the messages being returned by the ledger api, but it is boiler plate code that needs to be re-written each time. If you provided typed business exceptions, the boiler plate error handling code would be significantly reduced.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Types of Exceptions in Java - Stackify
Learn about the different types of exceptions in Java (checked and unchecked) and see specific examples.
Read more >Types of Exception in Java with Examples - GeeksforGeeks
Java defines several types of exceptions that relate to its various class libraries. Java also allows users to define their own exceptions.
Read more >Java Exceptions Hierarchy Explained - Rollbar
Exceptions that can occur at compile-time are called checked exceptions since they need to be explicitly checked and handled in code. Classes ...
Read more >Common Java Exceptions - Baeldung
This tutorial focuses on some common Java exceptions. ... This class is then subclassed into checked exceptions and unchecked exceptions.
Read more >11.2. Compile-Time Checking of Exceptions
The Java programming language requires that a program contains handlers for checked exceptions which can result from execution of a method or constructor....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
One additional note: we might want to add something like
we should add that and turn it on by default on the sandbox. if you build applications against it, it will inject random failures to force you to think about error handling (and let you test your error handling).
@StephenOTT Please have a read about our error codes: https://docs.daml.com/app-dev/grpc/error-codes.html#work-with-error-codes
I would strongly advise to not invent another way to handle errors, but rather make the error-code information accessible.