Skip to content

Commit

Permalink
Add try/catch to catch duplicate path + general exceptions (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
svdv22 authored Jul 31, 2024
1 parent 825cb9c commit b1a43bc
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/GraphQL/Mutation/MutationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,20 @@ public function buildDataObjectMutations(&$config = [], $context = [])
}
}

$me->saveElement($newInstance, $args);
try {
$me->saveElement($newInstance, $args);
} catch (DuplicateFullPathException $e) {
return [
'success' => false,
'message' => 'creating failed: Duplicate path',
];
} catch (\Exception $e) {
return [
'success' => false,
'message' => 'creating failed: ' . $e->getMessage(),
];
}


if ($tags) {
$me->setTags('object', $newInstance->getId(), $tags);
Expand Down

0 comments on commit b1a43bc

Please sign in to comment.