catch money exceptions
This commit is contained in:
parent
996d60c456
commit
c6276a88a6
@ -3,6 +3,9 @@
|
|||||||
namespace App\Traits;
|
namespace App\Traits;
|
||||||
|
|
||||||
use Akaunting\Money\Money;
|
use Akaunting\Money\Money;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use OutOfBoundsException;
|
||||||
|
use UnexpectedValueException;
|
||||||
|
|
||||||
trait Currencies
|
trait Currencies
|
||||||
{
|
{
|
||||||
@ -15,7 +18,13 @@ trait Currencies
|
|||||||
return $format ? $money->format() : $money->getAmount();
|
return $format ? $money->format() : $money->getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
$money = $money->$method((double) $rate);
|
try {
|
||||||
|
$money = $money->$method((double) $rate);
|
||||||
|
} catch (InvalidArgumentException | OutOfBoundsException | UnexpectedValueException $e) {
|
||||||
|
logger($e->getMessage());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $format ? $money->format() : $money->getAmount();
|
return $format ? $money->format() : $money->getAmount();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user