Skip to content

Commit

Permalink
Add translate inside Exception Catch
Browse files Browse the repository at this point in the history
Instead of showing an Exception error return a message error via Filament notification method.
  • Loading branch information
EGYWEB-Mohamed authored Jan 27, 2024
1 parent 2cc2dcd commit 93644e2
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Actions/TranslatableAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ function (Field $component) {
} else {
$text = $component->getState();
}

$googleTranslate = $googleTranslate->translate($source, $data['target'], $text);


try {
$googleTranslate = $googleTranslate->translate($source, $data['target'], $text);
$component->state($googleTranslate);

$livewire->dispatch('refresh-tiptap-editors', [
Expand All @@ -66,7 +65,7 @@ function (Field $component) {
} catch (\Exception $exception) {
Notification::make()
->title(__('filament-translate-action::filament-translate-action.error_title'))
->body(__('filament-translate-action::filament-translate-action.error_message'))
->body(__('filament-translate-action::filament-translate-action.error_message'). '<br/>' . $exception->getMessage())
->danger()
->send();

Expand Down

0 comments on commit 93644e2

Please sign in to comment.