We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
DPC2019: Exception design - the art of making debugging more accurate - Szymon Szymański
Improve your code's debugging capabilities with a thoughtful approach to exception design, including naming conventions, exception chaining, and more.
- Exceptions are a powerful tool for improving code readability and better understanding of code intent.
- Exceptions should not be used as a catch-all for every error, but only for exceptional situations.
- The name of the exception should provide a hint about what went wrong and what the user can do to fix the issue.
- Exception chaining can be used to create a history of the problem, making it easier for developers to debug.
- The decision to use exceptions should be based on the probability of the problem and the business context.
- Namespaces can be used to group related exceptions together and make them easier to manage.
- Exceptions can be created from anywhere, but it’s generally better to create them as close to the source of the problem as possible.
- Exception messages can be short and concise, but should still provide enough information to help the user understand what went wrong.
- Exception messages should be designed to be machine parseable, to make it easier for tools to automatically detect and handle exceptions.
- Exceptions can be used to control the flow of the program, but should not be used as a replacement for conditional logic.
- The context of the exception should be considered, including the severity of the error and the type of user who will be affected.
- The choice between different exception types, such as exceptions and runtime exceptions, should be based on the specific requirements of the application.
- The importance of abstraction in exceptions, including using abstract classes and interfaces to create a hierarchy of exceptions.