Replies: 1 comment 4 replies
-
|
I agree that the error handling can be improved. The point of using |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment



Uh oh!
There was an error while loading. Please reload this page.
-
Working on PR #1511, I noticed that the error handling in common.py was a bit bloated in general, probably due to legacy code not being updated, several people working on it, etc. I found a couple code patterns where it's clear that a try-except block is unnecessary. I included examples of these patterns below.
Catches an exception only to re-raise it.

Catches an exception and simply prints the error message.

Catches an exception, repackages it in a less specific Exception and re-raises.

For the first case, the try-except block will actually not do anything, so it can be removed without any change in behavior.
The second case technically prevents the error from being raised while still providing info about it. The error catching for the second case unnecessary and arguably misleading, since the receiving an error communicates to the user that something went wrong better than just a print statement. Errors may look ugly, but they should be raised, especially if the user's command did not go through.
The third case is unnecessary because the ImportError by itself is already alerting the user to the fact that they need to install the missing package. Repackaging it into a generic Exception with a different message may make the problem more difficult to resolve. A user will find much more information about how to solve a ImportError rather than a generic exception with geemap's specific error message.
As mentioned in #1511, there still remains room for bugs in common.py, especially in the error handling. Reducing unneeded try-except blocks would help narrow down the room for bugs. I would love to hear your thoughts on this refactoring proposal
Beta Was this translation helpful? Give feedback.
All reactions