Handle errors internally and show them via the API #25

Merged
paul merged 3 commits from handle-errors into main 2022-06-06 16:49:03 +02:00
Owner
  • The map endpoints return an HTTP 404 error in case of unknown or out-of-bound locations
  • The forecast endpoint with an address returns an HTTP 404 with error JSON in case geocoding fails
  • The forecast endpoints return the errors per metric in the errors field of the forecast
  • Implement Display for Metric
  • Use a BTreeMap to have an ordered errors field/object
  • Also log the errors to the console
  • Update the tests
  • Document the errors that can occur
  • Introduce error types internally, switch to Results everywhere

This closes #5.

* The map endpoints return an HTTP 404 error in case of unknown or out-of-bound locations * The forecast endpoint with an address returns an HTTP 404 with error JSON in case geocoding fails * The forecast endpoints return the errors per metric in the `errors` field of the forecast * Implement `Display` for `Metric` * Use a `BTreeMap` to have an ordered `errors` field/object * Also log the errors to the console * Update the tests * Document the errors that can occur * Introduce error types internally, switch to Results everywhere This closes #5.
paul added the
enhancement
label 2022-06-06 16:41:13 +02:00
paul self-assigned this 2022-06-06 16:41:13 +02:00
paul added 3 commits 2022-06-06 16:41:14 +02:00
69ef08002c
Introduce error types, switch to Results everywhere
* Add dependency on the `thiserror` crate
* Add a global `Error` type, but also `maps::Error` and
  `providers::combined::MergeError` for convenience
* Add matching `Result` types that default to the respective `Error`
  type
* Refactor code to yield all kinds of error variants
* Add FIXMEs where library errors still need to be handled
* Remove documentation that explained why `None` was returned, this is
  captured in the error now
bf1faf7a66
Handle errors on the API side
* The map endpoints return an HTTP 404 error in case of unknown or
  out-of-bound locations
* The forecast endpoint with an address returns an HTTP 404 with
  error JSON in case geocoding fails
* The forecast endpoints return the errors per metric in the `errors`
  field of the forecast
* Implement `Display` for `Metric`
* Use a `BTreeMap` to have an ordered `errors` field/object
* Also log the errors to the console
* Update the tests
* Document the errors that can occur
paul force-pushed handle-errors from bf1faf7a66 to 014ca5a151 2022-06-06 16:47:39 +02:00 Compare
paul merged commit dc47c1c73c into main 2022-06-06 16:49:03 +02:00
paul deleted branch handle-errors 2022-06-06 16:49:04 +02:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: paul/sinoptik#25
No description provided.