Skip to content

Commit 75dfbb4

Browse files
committed
FIX Migliorata la stampa dell'errore in caso di validazione errata con tutti gli attributi del model prima faceva tante entry nel log adesso un unica entry che con sistemi tipo logViewer si legge meglio e se mandiamo ad un servizio in cloud conta una sola request anzichè n request.
1 parent 5d9b47f commit 75dfbb4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/Validable.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,15 @@ public function validate()
7272
$msg .= 'Attributi del model:';
7373
$msg .= $this->toJson(JSON_PRETTY_PRINT);
7474
$msg .= 'Errori di validazione:';
75-
$msg .= $this->getErrors();
76-
$msg .= 'StackTrace:'.PHP_EOL;
75+
$getErrors = $this->getErrors();
76+
try {
77+
if (count($getErrors) > 0) {
78+
$msg .= json_encode($getErrors, JSON_PRETTY_PRINT);
79+
}
80+
} catch (\Throwable $e) {
81+
$msg .= $e->getMessage();
82+
}
83+
$msg .= 'StackTrace:' . PHP_EOL;
7784
ob_start();
7885
debug_print_backtrace();
7986
$StackTrace = ob_get_contents();

0 commit comments

Comments
 (0)