Skip to content

Non-200 network errors are not well described in cross platform client #20

@AlexBrandes

Description

@AlexBrandes

When a network request receives a non-200 response from the cross-platform client, the error returned is not helpful and doesn't indicate the response code that was received. Debugging these issues would be much easier if we returned the response code.

Error thrown at:
https://github.com/StardustCollective/dag4.js/blob/main/packages/dag4-core/src/cross-platform/clients/fetch.http.ts#L62

Example current error output:

/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70
            throw new Error(text);
                  ^
Error
    at FetchRestService.<anonymous> (/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70:19)
    at Generator.next (<anonymous>)
    at fulfilled (/project/node_modules/@stardust-collective/dag4-core/dist/cjs/cross-platform/clients/fetch.http.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Expected output example:

/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70
            throw new Error(text);
                  ^
Network Error Response
  url: https://be-mainnet.constellationnetwork.io/cluster/info
  responseCode: 400
  message: Invalid parameter
    at FetchRestService.<anonymous> (/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70:19)
    at Generator.next (<anonymous>)
    at fulfilled (/project/node_modules/@stardust-collective/dag4-core/dist/cjs/cross-platform/clients/fetch.http.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions