js-waku icon indicating copy to clipboard operation
js-waku copied to clipboard

feat: prefer error code for req-res protocol over exception

Open fryorcraken opened this issue 1 year ago • 1 comments

This is a bug report/feature or change request/support request

Problem

Protocols currently use different pattern to handle errors. Light push uses error code while filter uses exception.

It is best for the user if a common pattern is used across the API. Also, there is an opportunity to re-use error code across the codebase and have similar pattern on the user side to handle them:

https://github.com/waku-org/js-waku/blob/b7dc3d7576e9444a5acbb036812c05cfccb25815/packages/interfaces/src/protocols.ts#L67

Proposed Solutions

Generally avoid usage of exception in all protocols (store, light push, filter, metadata) in favour of error code. Encourage developers to monitor this error code to recover from issue, e,g,:

  • try again
  • show user loss of internet access
  • reporting of internal error
  • etc

PRs

  • [x] metadata: https://github.com/waku-org/js-waku/pull/1904
  • [x] peer-exchange: https://github.com/waku-org/js-waku/pull/1907
  • [x] filter: https://github.com/waku-org/js-waku/pull/1971
  • [x] lightpush: https://github.com/waku-org/js-waku/pull/1971
  • [ ] store

Notes

fryorcraken avatar Oct 27 '23 05:10 fryorcraken

Only Store remains from this issue. Moving back to TODO as this is low priority. Might address it with #1685

danisharora099 avatar May 14 '24 13:05 danisharora099

I believe it can be closed

weboko avatar Jul 23 '24 15:07 weboko