Skip to content

feat: mapping statusCode to tangible errors #1999

Open
@danisharora099

Description

@danisharora099

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
      };
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions