mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
Add db-error code file
This commit is contained in:
parent
063d3f0e4a
commit
d1d271bb41
@ -4,6 +4,7 @@ const metricsHelper = require('../metrics-helper');
|
|||||||
const { DB_TIME } = require('../events');
|
const { DB_TIME } = require('../events');
|
||||||
const NotFoundError = require('../error/notfound-error');
|
const NotFoundError = require('../error/notfound-error');
|
||||||
const FeatureHasTagError = require('../error/feature-has-tag-error');
|
const FeatureHasTagError = require('../error/feature-has-tag-error');
|
||||||
|
const { UNIQUE_CONSTRAINT_VIOLATION } = require('../error/db-error');
|
||||||
|
|
||||||
const FEATURE_COLUMNS = [
|
const FEATURE_COLUMNS = [
|
||||||
'name',
|
'name',
|
||||||
@ -242,7 +243,7 @@ class FeatureToggleStore {
|
|||||||
await this.db(FEATURE_TAG_TABLE)
|
await this.db(FEATURE_TAG_TABLE)
|
||||||
.insert(this.featureAndTagToRow(featureName, tag))
|
.insert(this.featureAndTagToRow(featureName, tag))
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
if (err.code === '23505') {
|
if (err.code === UNIQUE_CONSTRAINT_VIOLATION) {
|
||||||
throw new FeatureHasTagError(
|
throw new FeatureHasTagError(
|
||||||
`${featureName} already had the tag: [${tag.type}:${tag.value}]`,
|
`${featureName} already had the tag: [${tag.type}:${tag.value}]`,
|
||||||
);
|
);
|
||||||
|
3
lib/error/db-error.js
Normal file
3
lib/error/db-error.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
UNIQUE_CONSTRAINT_VIOLATION: '23505',
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user