Skip to content

Commit

Permalink
feat: catch errors (#199)
Browse files Browse the repository at this point in the history
* feat: catch errors

* style: formatting
  • Loading branch information
64knl authored Feb 12, 2024
1 parent f753544 commit d93c1c6
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/Http/Controllers/CmsEditor/CmsEditorImportExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ public function exportAllTables()
$tables = Table::all();

foreach ($tables as $table) {
// TODO: catch exceptions
$table->exportToFile();
try {
$table->exportToFile();
} catch (\Exception $e) {
$response->addAction(
new Toast('Error exporting table '.$table->name.': '.$e->getMessage())
);

return $response->build();
}
}

$response->addAction(
new Toast($tables->count().' tables exported successfully')
);
Expand All @@ -33,10 +39,16 @@ public function exportAllTemplates()
$templates = Template::all();

foreach ($templates as $template) {
// TODO: catch exceptions
$template->exportToFile();
try {
$template->exportToFile();
} catch (\Exception $e) {
$response->addAction(
new Toast('Error exporting template '.$template->name.': '.$e->getMessage())
);

return $response->build();
}
}

$response->addAction(
new Toast($templates->count().' templates exported successfully')
);
Expand Down

0 comments on commit d93c1c6

Please sign in to comment.