xmtp / libxmtp

LibXMTP is a shared library encapsulating the core functionality of the XMTP messaging protocol, such as cryptography, networking, and language bindings.
MIT License
42 stars 18 forks source link

Remove `Error::Generic` variants in favor of more specific errors #1083

Open insipx opened 2 weeks ago

insipx commented 2 weeks ago

Generic should not be used, instead we should prefer creating a new enum variant in almost all cases. Using "Generic" errors may lead to depending on strings in an a variant leading to difficult to find bugs.

If a string changes in one part of a codebase, it could inadvertently lead to very bad things happening if the author is not careful (silenced errors no longer becoming silenced, retryable errors no longer being retried, etc.).

Enum variants will give a compile time error and force the author to fix.

re: this comment: https://github.com/xmtp/libxmtp/blob/cd0fc5cb43e000a4cca7bc2c3007957c03ae2555/xmtp_mls/src/storage/errors.rs#L60

neekolas commented 2 weeks ago

❤️