Skip to content

Commit 877952b

Browse files
fix: generic template title max length error (#1583)
2 parents cf29dd0 + 46b6ee5 commit 877952b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

apps/backend/src/datasources/postgres/GenericTemplateDataSource.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ export default class PostgresGenericTemplateDataSource
125125
return createGenericTemplateObject(records[0]);
126126
})
127127
.catch((err) => {
128-
return err;
128+
if (err.message.includes('value too long')) {
129+
throw new GraphQLError(
130+
'The title exceeds the maximum allowed length'
131+
);
132+
}
133+
134+
throw err;
129135
});
130136
}
131137

apps/backend/src/mutations/GenericTemplateMutations.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GraphQLError } from 'graphql/error/GraphQLError';
12
import { container, inject, injectable } from 'tsyringe';
23

34
import { GenericTemplateAuthorization } from '../auth/GenericTemplateAuthorization';
@@ -92,6 +93,10 @@ export default class GenericTemplateMutations {
9293
);
9394
})
9495
.catch((error) => {
96+
if (error instanceof GraphQLError) {
97+
throw error;
98+
}
99+
95100
return rejection(
96101
'Can not create genericTemplate because an error occurred',
97102
{ agent, args },

0 commit comments

Comments
 (0)