From b169f99f3d76217ee418aac50e55844b878ac06e Mon Sep 17 00:00:00 2001 From: Sven van der Veldt Date: Mon, 27 May 2024 10:17:54 +0200 Subject: [PATCH] #865 add try/catch to catch duplicate path + general exceptions --- src/GraphQL/Mutation/MutationType.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/GraphQL/Mutation/MutationType.php b/src/GraphQL/Mutation/MutationType.php index 8aaff3bf..f9f1f559 100644 --- a/src/GraphQL/Mutation/MutationType.php +++ b/src/GraphQL/Mutation/MutationType.php @@ -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' => 'saving failed: Duplicate path', + ]; + } catch (\Exception $e) { + return [ + 'success' => false, + 'message' => 'saving failed: ' . $e->getMessage(), + ]; + } + if ($tags) { $me->setTags('object', $newInstance->getId(), $tags);