How to use generated exceptions
See original GitHub issueSo I’m trying to use SSM and catch scenario where value doesn’t exist. The call generates botocore.errorfactory.ParameterNotFound: An error occurred (ParameterNotFound) when calling the GetParameter operation
The thing is that ParameterNotFound does not exist the class with the error is dynamically generated and I can’t reference it in the code (or at least not from botocore.errorfactory.ParameterNotFound
). What’s the point of having exceptions like this when they can’t be caught? Why bothering with dynamically generated class, when you could just have a generic error and inside of its properties I could extract the actual cause. Or is there a way to use it that I’m not aware of?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
[Chapter 4] 4.3 Generating Exceptions
4.3 Generating Exceptions ... A Java program can use the exception-handling mechanism to deal with program-specific errors in a clean manner. A program...
Read more >Handling XML GENERATE exceptions - IBM
To handle errors, use either or both of the following phrases of the XML GENERATE statement: ON EXCEPTION; COUNT IN. If you code...
Read more >Compiler-generated exceptions | Microsoft Learn
Learn about compiler-generated exceptions. Review a list of automatically thrown exceptions and their error conditions.
Read more >How to Throw Exceptions in Java - Rollbar
Throwing an exception is as simple as using the "throw" statement. You then specify the Exception object you wish to throw. Every Exception...
Read more >8. Errors and Exceptions — Python 3.11.1 documentation
When an exception is created in order to be raised, it is usually initialized with information that describes the error that has occurred....
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 Free
Top 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
Yes, this is what I ended up doing, my point is that those dynamically generated classes for exceptions are pointless. You don’t have a static class that you can use to catch them, thankfully they all inherit from
ClientError
so one can catch them the way you showed the problem is that when you seebotocore.errorfactory.ParameterNotFound
it’s not obvious how to handle it. You don’t know that it inherits fromClientError
and you don’t know that exception name could be the error code. I would like to propose abolish the dynamic classes and simply raiseClientError
so it showsClientError('ParameterNotFound', ...)
or similar that makes it clear what exception happened and how to catch it.@takeda - Modeled exceptions can be accessed through the client. Instead of
botocore.errorfactory.ParameterNotFound
you can doclient.exceptions.ParameterNotFound
.I agree that this is confusing and the current documentation is insufficient. More information on this can be found at this pr: boto/botocore#1113 .