Catch NodeUpdateService in EditNode & NodeController (#1106)

This commit is contained in:
MartinOscar 2025-03-18 23:07:40 +01:00 committed by GitHub
parent e5d9d53aa3
commit c5230efad6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 6 deletions

View File

@ -555,7 +555,18 @@ class EditNode extends EditRecord
->modalHeading(trans('admin/node.reset_token'))
->modalDescription(trans('admin/node.reset_help'))
->action(function (Node $node) {
$this->nodeUpdateService->handle($node, [], true);
try {
$this->nodeUpdateService->handle($node, [], true);
} catch (Exception) {
Notification::make()
->title(trans('admin/node.error_connecting', ['node' => $node->name]))
->body(trans('admin/node.error_connecting_description'))
->color('warning')
->icon('tabler-database')
->warning()
->send();
}
Notification::make()->success()->title(trans('admin/node.token_reset'))->send();
$this->fillForm();
}),

View File

@ -15,6 +15,7 @@ use App\Http\Requests\Api\Application\Nodes\DeleteNodeRequest;
use App\Http\Requests\Api\Application\Nodes\UpdateNodeRequest;
use App\Http\Controllers\Api\Application\ApplicationApiController;
use Dedoc\Scramble\Attributes\Group;
use Exception;
#[Group('Node', weight: 0)]
class NodeController extends ApplicationApiController
@ -95,11 +96,15 @@ class NodeController extends ApplicationApiController
*/
public function update(UpdateNodeRequest $request, Node $node): array
{
$node = $this->updateService->handle(
$node,
$request->validated(),
$request->input('reset_secret') === true
);
try {
$node = $this->updateService->handle(
$node,
$request->validated(),
$request->input('reset_secret') === true
);
} catch (Exception $exception) {
report($exception);
}
return $this->fractal->item($node)
->transformWith($this->getTransformer(NodeTransformer::class))