Standardize Open Payment errors
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
@sabineschaller Please assign this to me.
Can you assign this issue to me so I can work on it?
Hey @anurag629 & @Jacintomuambumba, did you end up starting on this issue?
Iám working
Reopening while I add additional related PRs