OCHA-DAP / hdx-cli-toolkit

A commandline tool for interacting with HDX with a view to doing bulk updates
MIT License
1 stars 0 forks source link

Wrap calls to HDX to provide better errors #14

Closed IanHopkinson closed 8 months ago

IanHopkinson commented 8 months ago

For the update command we trap the HDXError exception and provide a nice error report if there is an Authorization Error. It would be good to do this for all live calls to HDX and extend the processing of errors (although Authorization Error is likely to be the main one).

Potentially a check of authorization could be made in the "configuration" command.

IanHopkinson commented 8 months ago

This shows how to use a decorator to handle exceptions neatly - just apply an appropriate decorator to all the hdx_utilities functions:

https://rinaarts.com/declutter-python-code-with-error-handling-decorators/

IanHopkinson commented 8 months ago

Added in #24