Properly handle errors

Created on 30 June 2025, 5 days ago

Problem/Motivation

Copy&paste from a first-glance review via email:

In the code, some of the error handling looks fishy. For example:

    $merchantRefundResponse = $client->postOrderRefund($remoteId, 
$refundRequest);
     if ($merchantRefundResponse === FALSE) {
       throw new PaymentGatewayException('Failed to create refund 
request on GNU Taler backend');
     }

discards all of the specifics as to WHY the backend failed (400 bad 
request, 500 internal server error, 403 permission denied, 410 too late 
to refund, money already transferred...). You probably should at least 
pass the "hint" from the JSON body (if present) or the HTTP status code 
into the exception (and/or log it?) so that if something goes wrong, the 
user/admin has a chance to diagnose the problem.
The same issue appears to happen on order creation and payment status 
checking -- if you don't get a 200, no details seem to be reported or 
logged (but maybe I'm missing something the Drupal framework does 
inherently?).

I'm also surprised that
     $this->mailHandler->sendMail($to, $subject, $body, $params);
cannot go wrong!?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇭Switzerland znerol

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024