diff --git a/be/app/Console/Commands/SyncVacationsFromIntranet.php b/be/app/Console/Commands/SyncVacationsFromIntranet.php index 224e80a..79aa0f5 100644 --- a/be/app/Console/Commands/SyncVacationsFromIntranet.php +++ b/be/app/Console/Commands/SyncVacationsFromIntranet.php @@ -2,8 +2,10 @@ namespace App\Console\Commands; +use App\Mail\Error; use App\Services\Intranet\IntranetService; use Illuminate\Console\Command; +use Illuminate\Support\Facades\Mail; class SyncVacationsFromIntranet extends Command { @@ -30,7 +32,14 @@ class SyncVacationsFromIntranet extends Command { $intranetService = new IntranetService(); - $intranetService->syncVacations(); + try { + $intranetService->syncVacations(); + } catch (\Exception $e) { + Mail::to('feher@studiotem.com')->send(new Error($e)); + + return Command::FAILURE; + } + return Command::SUCCESS; } } diff --git a/be/app/Mail/Error.php b/be/app/Mail/Error.php new file mode 100644 index 0000000..5b348b7 --- /dev/null +++ b/be/app/Mail/Error.php @@ -0,0 +1,64 @@ +message = $e->getMessage(); + } + + + /** + * Get the message envelope. + * + * @return \Illuminate\Mail\Mailables\Envelope + */ + public function envelope() + { + return new Envelope( + subject: 'Task Manager Error', + ); + } + + /** + * Get the message content definition. + * + * @return \Illuminate\Mail\Mailables\Content + */ + public function content() + { + return new Content( + view: 'emails.error', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments() + { + return []; + } +} diff --git a/be/resources/views/error.blade.php b/be/resources/views/error.blade.php new file mode 100644 index 0000000..24c01b6 --- /dev/null +++ b/be/resources/views/error.blade.php @@ -0,0 +1 @@ +Message: {{ $message }}