Urban-Analytics-Technology-Platform / popgetter-cli

A rust library and CLI for accessing popgetter data
0 stars 0 forks source link

Move error handling from anyhow to thiserror #25

Closed stuartlynn closed 3 weeks ago

stuartlynn commented 1 month ago

We are currently using anyhoo to propagate errors easily. This makes sense to continue using in the CLI but the library should define and use internal structured errors. We should switch from using anyhow in the library to using thiserror to define solid error types.

sgreenbury commented 1 month ago

Initial ideas for error type but see code to enrich this:

enum PopgetterError {
    FailedConnection,
    #[thiserror("")]
    MetricNotFound,
    /// Bad search syntax
    InvalidSearchQuery,
    /// Non-existent geometry for metric requested
    NonExistentGeometry
}
sgreenbury commented 1 month ago

Next step: add this basic enum as a start to a module and enrich as we go