coralnet / pyspacer

Python based tools for spatial image analysis
MIT License
6 stars 2 forks source link

Some more descriptive error classes #70

Closed StephenChan closed 7 months ago

StephenChan commented 7 months ago

Replaced all SpacerInputErrors and some AssertionErrors with more descriptive error classes: URLDownloadError, RowColumnMismatchError, RowColumnInvalidError, and DataLimitError.

In pyspacer 0.4.0, I had the idea of introducing the SpacerInputError class to indicate that an error was most likely caused by unexpected user inputs rather than by a pyspacer bug. However, now I consider that concept misguided for a pluggable app like pyspacer, because it shouldn't be able to tell who gets the "blame" for a particular error; that depends on the application.

So these new error classes just make an effort to group certain errors usefully, so that the caller can decide how to handle the errors appropriately based on context. Note that URLDownloadError is the most broad error and it actually wraps around the original error that spacer catches (can be a ValueError, urllib.error.URLError, or http.client.IncompleteRead), but the original error is available in the original_error field in case the caller wants it.