Skip to content

Commit d17c7fd

Browse files
authored
prevent profiler error if key does already exist
When the local storage is behind the remote storage (key to create already exists on remote) the response is an UnprocessableEntityException. In this case we must catch the exception to prevent the profiler request to fail.
1 parent 17029a9 commit d17c7fd

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/PhraseApp.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ public function create(Message $message)
105105
}
106106
}
107107

108-
/* @var KeyCreated $keyCreated */
109-
$keyCreated = $this->client->key()->create($this->projectId, $message->getDomain().'::'.$message->getKey(), [
110-
'tags' => $message->getDomain(),
111-
]);
108+
try {
109+
/* @var KeyCreated $keyCreated */
110+
$keyCreated = $this->client->key()->create($this->projectId, $message->getDomain().'::'.$message->getKey(), [
111+
'tags' => $message->getDomain(),
112+
]);
113+
} catch (UnprocessableEntityException $e) {
114+
// Translaton does already exist
115+
return;
116+
}
112117

113118
$this->client->translation()->create(
114119
$this->projectId,

0 commit comments

Comments
 (0)