NixOS / ofborg

@ofborg tooling automation https://monitoring.ofborg.org/dashboard/db/ofborg

Home Page:https://ofborg.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[tracking] Better error handling

cole-h opened this issue · comments

This is a general tracking issue for the removal of (or to at least greatly
diminish the presence of) unwraps and expects, to guard against runtime
panics.

Some tasks that come to mind:

  • Convert all Result<..., String> types to be Result<..., Error> and roll an
    Error enum for each place with a non-trivial amount of errors to handle
    • As a result (no pun intended), convert instances of unwrap/expect,
      wherever possible, to use the ? operator to propagate errors up
    • Maybe use anyhow to reduce boilerplate?
  • Remove as many instances of unwrap and expect as possible in order to
    decrease the occurrence of panics
    • At the very least, convert unwraps to expects, to indicate what the problem was and where it occurred

cc @grahamc

lgtm, but I strongly prefer the enum and impl From method of handling errors, the implementations are easy and a bit boilerplate heavy, but easy to understand and extend. I'd prefer going the route of more boilerplate but trivial to understand.