|
@@ -52,7 +52,25 @@ trait SendsPagarmeRequests
|
|
|
'result' => $responseBody,
|
|
'result' => $responseBody,
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
- throw new \RuntimeException($errorMessage, previous: $e);
|
|
|
|
|
|
|
+ $message = $errorMessage;
|
|
|
|
|
+
|
|
|
|
|
+ $errors = $responseBody['errors'] ?? [];
|
|
|
|
|
+
|
|
|
|
|
+ if ($errors) {
|
|
|
|
|
+ $details = [];
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($errors as $field => $msgs) {
|
|
|
|
|
+ foreach ((array) $msgs as $msg) {
|
|
|
|
|
+ $details[] = $msg;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if ($details) {
|
|
|
|
|
+ $message .= ': '.implode(' ', $details);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ throw new \RuntimeException($message, previous: $e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|