Skip to content

Commit

Permalink
feat: firestore new translated error
Browse files Browse the repository at this point in the history
  • Loading branch information
MXPOL committed Oct 11, 2023
1 parent eb346e0 commit 19cc425
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/external-db-firestore/src/sql_exception_translator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { errors } from '@wix-velo/velo-external-db-commons'
const { DbConnectionError, UnrecognizedError, ItemAlreadyExists } = errors
const { DbConnectionError, UnrecognizedError, ItemAlreadyExists, ItemDoesNotExists } = errors

const extractValue = (details: string, valueName: string) => extractValueFromErrorMessage(details, new RegExp(`${valueName}:\\s*"([^"]+)"`))

Expand All @@ -18,6 +18,8 @@ export const notThrowingTranslateErrorCodes = (err: any) => {
const itemId = extractValue(err.details, 'name')

switch (err.code) {
case 5:
return new ItemDoesNotExists(`Item doesn't exists: ${err.details}`, collectionName, itemId)
case 6:
return new ItemAlreadyExists(`Item already exists: ${err.details}`, collectionName, itemId)
case 7:
Expand Down

0 comments on commit 19cc425

Please sign in to comment.