mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Dont throw an exception, if we can not retrieve an currency exchange rate, but show an meaningful flash message
This commit is contained in:
parent
0c5180bda4
commit
2b2fc6f1e6
3 changed files with 22 additions and 3 deletions
|
@ -39,6 +39,7 @@ use App\Services\LogSystem\TimeTravel;
|
|||
use App\Services\StructuralElementRecursionHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Exchanger\Exception\ChainException;
|
||||
use Exchanger\Exception\Exception;
|
||||
use Exchanger\Exception\UnsupportedCurrencyPairException;
|
||||
use Omines\DataTablesBundle\DataTableFactory;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
@ -117,8 +118,8 @@ class CurrencyController extends BaseAdminController
|
|||
try {
|
||||
$this->exchangeRateUpdater->update($entity);
|
||||
$this->addFlash('info', 'currency.edit.exchange_rate_updated.success');
|
||||
} catch (ChainException $exception) {
|
||||
$exception = $exception->getExceptions()[0];
|
||||
} catch (Exception $exception) {
|
||||
//$exception = $exception->getExceptions()[0];
|
||||
if ($exception instanceof UnsupportedCurrencyPairException || false !== stripos($exception->getMessage(), 'supported')) {
|
||||
$this->addFlash('error', 'currency.edit.exchange_rate_update.unsupported_currency');
|
||||
} else {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
{{ form_row(form.exchange_rate) }}
|
||||
|
||||
{% if form.update_exchange_rate is defined %}
|
||||
{{ form_row(form.update_exchange_rate, {attr: {class: 'btn-link'}}) }}
|
||||
{{ form_row(form.update_exchange_rate, {attr: {class: 'btn-info'}}) }}
|
||||
{% endif %}
|
||||
{% if entity.inverseExchangeRate %}
|
||||
<span class="form-text text-muted offset-3 col-9">
|
||||
|
|
|
@ -9923,5 +9923,23 @@ Element 3</target>
|
|||
<target>IPN</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="1HcqCmo" name="currency.edit.update_rate">
|
||||
<segment>
|
||||
<source>currency.edit.update_rate</source>
|
||||
<target>Retrieve exchange rate</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="jSf6Wmz" name="currency.edit.exchange_rate_update.unsupported_currency">
|
||||
<segment>
|
||||
<source>currency.edit.exchange_rate_update.unsupported_currency</source>
|
||||
<target>The currency is unsupported by the exchange rate provider. Check your exchange rate provider configuration.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="D481NZD" name="currency.edit.exchange_rate_update.generic_error">
|
||||
<segment>
|
||||
<source>currency.edit.exchange_rate_update.generic_error</source>
|
||||
<target>Unable to retrieve the exchange rate. Check your exchange rate provider configuration.</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue