carboncredits / x4c

MIT License
2 stars 0 forks source link

Improve Error Handling #48

Closed patricoferris closed 1 year ago

patricoferris commented 2 years ago

Currently a lot of our interfaces don't do a great job of error handling. In the best case scenario at the moment we throw an error, in the worst case a good result could be a string and a bad result could be a string that says "Error: e.g.

https://github.com/carboncredits/x4c/blob/84a058ac8de6c4c104b247b48251340ccae9ecd5/cli/src/x4c/CustodianContract.ts#L147

Unfortunately, this then propagates all the way up as far as assuming we made a successful retirement but in fact we didn't.

I propose we either:

  1. Lift our exceptions into values and have some result type. As an OCaml dev this makes me happy :))
  2. Make sure we re-raise exceptions instead of swallowing them

Any thoughts @mdales ?

patricoferris commented 1 year ago

With the changes to use Go etc. we're in a much better position w.r.t to error handling, happy to close this now