Add exceptions for metadata modules (#6070)
Class exception for each metadata module + handler to map on graphql error TODO left : - find a way to call handler on auto-resolvers nestjs query (probably interceptors) - discuss what should be done for pre-hooks errors - discuss what should be done for Unauthorized exception
This commit is contained in:
@ -12,6 +12,7 @@ import {
|
||||
UpdateOneObjectInput,
|
||||
} from 'src/engine/metadata-modules/object-metadata/dtos/update-object.input';
|
||||
import { BeforeUpdateOneObject } from 'src/engine/metadata-modules/object-metadata/hooks/before-update-one-object.hook';
|
||||
import { objectMetadataGraphqlApiExceptionHandler } from 'src/engine/metadata-modules/object-metadata/utils/object-metadata-graphql-api-exception-handler.util';
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Resolver(() => ObjectMetadataDTO)
|
||||
@ -26,7 +27,11 @@ export class ObjectMetadataResolver {
|
||||
@Args('input') input: DeleteOneObjectInput,
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
) {
|
||||
return this.objectMetadataService.deleteOneObject(input, workspaceId);
|
||||
try {
|
||||
return this.objectMetadataService.deleteOneObject(input, workspaceId);
|
||||
} catch (error) {
|
||||
objectMetadataGraphqlApiExceptionHandler(error);
|
||||
}
|
||||
}
|
||||
|
||||
@Mutation(() => ObjectMetadataDTO)
|
||||
@ -34,8 +39,12 @@ export class ObjectMetadataResolver {
|
||||
@Args('input') input: UpdateOneObjectInput,
|
||||
@AuthWorkspace() { id: workspaceId }: Workspace,
|
||||
) {
|
||||
await this.beforeUpdateOneObject.run(input, workspaceId);
|
||||
try {
|
||||
await this.beforeUpdateOneObject.run(input, workspaceId);
|
||||
|
||||
return this.objectMetadataService.updateOneObject(input, workspaceId);
|
||||
return this.objectMetadataService.updateOneObject(input, workspaceId);
|
||||
} catch (error) {
|
||||
objectMetadataGraphqlApiExceptionHandler(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user