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

feat: mapping `statusCode` to tangible errors

Open danisharora099 opened this issue 3 months ago • 4 comments

This is a feature request

Problem

For protocol implementations (eg Filter), we have access to certain statusCode that the remote peer might respond with. Based on specific statusCode, returning and handling errors appropriately would be great devex.

Proposed Solutions

Map error codes received from remote peers into tangible errors

Notes

We currently do follow generic error handling based on statusCode but the aim is to do it for more precise error codes:

 const { statusCode, requestId, statusDesc } =
      FilterSubscribeResponse.decode(res[0].slice());

    if (statusCode < 200 || statusCode >= 300) {
      log.error(
        `Filter unsubscribe all request ${requestId} failed with status code ${statusCode}: ${statusDesc}`
      );
      return {
        failure: {
          error: ProtocolError.REMOTE_PEER_REJECTED,
          peerId: peer.id
        },
        success: null
      };
    }

danisharora099 avatar May 07 '24 07:05 danisharora099