Skip to content

Commit 3dee042

Browse files
authored
Fixed PHP warning raised when displaying order error messages (#272)
* Fixed PHP warning raised when displaying order error messages * fix phpcs
1 parent 6f38a3b commit 3dee042

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

app/code/Meta/Sales/Observer/Order/Cancel.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ private function cancelOrder(int $storeId, string $fbOrderId)
9999
} catch (GuzzleException $e) {
100100
$response = $e->getResponse();
101101
$body = json_decode($response->getBody());
102-
throw new Exception('Error Code: '
103-
.(string) $body->error->code
104-
.'; '
105-
. (string) $body->error->error_user_msg);
102+
throw new Exception(__(
103+
'Error code: "%1"; Error message: "%2"',
104+
(string)$body->error->code,
105+
(string)($body->error->message ?? $body->error->error_user_msg)
106+
));
106107
}
107108
}
108109
}

app/code/Meta/Sales/Observer/Order/MarkAsShipped.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ public function execute(Observer $observer)
9595
} catch (GuzzleException $e) {
9696
$response = $e->getResponse();
9797
$body = json_decode($response->getBody());
98-
throw new Exception('Error Code: '
99-
.(string) $body->error->code
100-
.'; '
101-
. (string) $body->error->error_user_msg);
98+
throw new Exception(__(
99+
'Error code: "%1"; Error message: "%2"',
100+
(string)$body->error->code,
101+
(string)($body->error->message ?? $body->error->error_user_msg)
102+
));
102103
}
103104
}
104105
}

app/code/Meta/Sales/Observer/Order/Refund.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,11 @@ private function refundOrder(
171171
} catch (GuzzleException $e) {
172172
$response = $e->getResponse();
173173
$body = json_decode($response->getBody());
174-
throw new Exception('Error Code: '
175-
.(string) $body->error->code
176-
.'; '
177-
. (string) $body->error->error_user_msg);
174+
throw new Exception(__(
175+
'Error code: "%1"; Error message: "%2"',
176+
(string)$body->error->code,
177+
(string)($body->error->message ?? $body->error->error_user_msg)
178+
));
178179
}
179180
}
180181

0 commit comments

Comments
 (0)