rafiki icon indicating copy to clipboard operation
rafiki copied to clipboard

Standardize Open Payment errors

Open mkurapov opened this issue 2 years ago • 5 comments

We should standardize errors that get thrown in the Open Payments API, so we can return proper error codes and messages in the API response.

Potentially, we could do something like:

class OpenPaymentsError extends Error { 
    constructor(message: string, status: number) {
      super(`Open Payments API error: ${message}`);
      this.name = 'OpenPaymentsError';
      this.status = status
    }
}


throw new OpenPaymentsError('Could not get Incoming Payment', 404); // usage

and then use a middleware to properly format those errors when thrown in the Open Payment routes. This will also help standardize usage for the Open Payments client: https://github.com/interledger/open-payments/tree/main/packages/open-payments

mkurapov avatar Sep 19 '23 06:09 mkurapov

@sabineschaller Please assign this to me.

anurag629 avatar Oct 03 '23 18:10 anurag629

Can you assign this issue to me so I can work on it?

Jacintomuambumba avatar Oct 17 '23 10:10 Jacintomuambumba

Hey @anurag629 & @Jacintomuambumba, did you end up starting on this issue?

mkurapov avatar Jan 08 '24 15:01 mkurapov

Iám working

Jacintomuambumba avatar Jan 09 '24 08:01 Jacintomuambumba

Reopening while I add additional related PRs

mkurapov avatar May 07 '24 13:05 mkurapov