mirror of
				https://github.com/lingble/twenty.git
				synced 2025-10-30 20:27:55 +00:00 
			
		
		
		
	| @@ -1,7 +1,5 @@ | |||||||
| import { HttpException } from '@nestjs/common'; | import { HttpException } from '@nestjs/common'; | ||||||
|  |  | ||||||
| import { TypeORMError } from 'typeorm'; |  | ||||||
|  |  | ||||||
| import { | import { | ||||||
|   AuthenticationError, |   AuthenticationError, | ||||||
|   BaseGraphQLError, |   BaseGraphQLError, | ||||||
| @@ -29,12 +27,10 @@ export const handleException = ( | |||||||
|   exception: Error, |   exception: Error, | ||||||
|   exceptionHandlerService: ExceptionHandlerService, |   exceptionHandlerService: ExceptionHandlerService, | ||||||
| ): void => { | ): void => { | ||||||
|   if ( |   if (exception instanceof HttpException && exception.getStatus() < 500) { | ||||||
|     exception instanceof TypeORMError || |     return; | ||||||
|     (exception instanceof HttpException && exception.getStatus() >= 500) |  | ||||||
|   ) { |  | ||||||
|     exceptionHandlerService.captureException(exception); |  | ||||||
|   } |   } | ||||||
|  |   exceptionHandlerService.captureException(exception); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| export const convertExceptionToGraphQLError = ( | export const convertExceptionToGraphQLError = ( | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ export class ExceptionHandlerSentryDriver | |||||||
| { | { | ||||||
|   constructor(options: ExceptionHandlerSentryDriverFactoryOptions['options']) { |   constructor(options: ExceptionHandlerSentryDriverFactoryOptions['options']) { | ||||||
|     Sentry.init({ |     Sentry.init({ | ||||||
|       dsn: options.dns, |       dsn: options.dsn, | ||||||
|       integrations: [ |       integrations: [ | ||||||
|         // enable HTTP calls tracing |         // enable HTTP calls tracing | ||||||
|         new Sentry.Integrations.Http({ tracing: true }), |         new Sentry.Integrations.Http({ tracing: true }), | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ export const exceptionHandlerModuleFactory = async ( | |||||||
|       return { |       return { | ||||||
|         type: ExceptionHandlerDriver.Sentry, |         type: ExceptionHandlerDriver.Sentry, | ||||||
|         options: { |         options: { | ||||||
|           dns: environmentService.getSentryDSN() ?? '', |           dsn: environmentService.getSentryDSN() ?? '', | ||||||
|           serverInstance: adapterHost.httpAdapter?.getInstance(), |           serverInstance: adapterHost.httpAdapter?.getInstance(), | ||||||
|           debug: environmentService.isDebugMode(), |           debug: environmentService.isDebugMode(), | ||||||
|         }, |         }, | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ export enum ExceptionHandlerDriver { | |||||||
| export interface ExceptionHandlerSentryDriverFactoryOptions { | export interface ExceptionHandlerSentryDriverFactoryOptions { | ||||||
|   type: ExceptionHandlerDriver.Sentry; |   type: ExceptionHandlerDriver.Sentry; | ||||||
|   options: { |   options: { | ||||||
|     dns: string; |     dsn: string; | ||||||
|     serverInstance?: Router; |     serverInstance?: Router; | ||||||
|     debug?: boolean; |     debug?: boolean; | ||||||
|   }; |   }; | ||||||
|   | |||||||
| @@ -19,14 +19,10 @@ export class FieldMetadataResolver { | |||||||
|     @Args('input') input: CreateOneFieldMetadataInput, |     @Args('input') input: CreateOneFieldMetadataInput, | ||||||
|     @AuthWorkspace() { id: workspaceId }: Workspace, |     @AuthWorkspace() { id: workspaceId }: Workspace, | ||||||
|   ) { |   ) { | ||||||
|     try { |  | ||||||
|     return this.fieldMetadataService.createOne({ |     return this.fieldMetadataService.createOne({ | ||||||
|       ...input.field, |       ...input.field, | ||||||
|       workspaceId, |       workspaceId, | ||||||
|     }); |     }); | ||||||
|     } catch (error) { |  | ||||||
|       console.log(error); |  | ||||||
|     } |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   @Mutation(() => FieldMetadataDTO) |   @Mutation(() => FieldMetadataDTO) | ||||||
|   | |||||||
| @@ -56,7 +56,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit | |||||||
|       ); |       ); | ||||||
|  |  | ||||||
|     if (!objectMetadata) { |     if (!objectMetadata) { | ||||||
|       throw new Error('Object does not exist'); |       throw new NotFoundException('Object does not exist'); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const fieldAlreadyExists = await this.fieldMetadataRepository.findOne({ |     const fieldAlreadyExists = await this.fieldMetadataRepository.findOne({ | ||||||
|   | |||||||
| @@ -24,9 +24,9 @@ export const metadataModuleFactory = async ( | |||||||
|           error.originalError, |           error.originalError, | ||||||
|           exceptionHandlerService, |           exceptionHandlerService, | ||||||
|         ); |         ); | ||||||
|       } else { |  | ||||||
|         return maskError(error, message, isDev); |  | ||||||
|       } |       } | ||||||
|  |  | ||||||
|  |       return maskError(error, message, isDev); | ||||||
|     }, |     }, | ||||||
|   }, |   }, | ||||||
| }); | }); | ||||||
|   | |||||||
| @@ -6,6 +6,7 @@ import { YogaDriverConfig, YogaDriver } from '@graphql-yoga/nestjs'; | |||||||
| import { WorkspaceMigrationRunnerModule } from 'src/workspace/workspace-migration-runner/workspace-migration-runner.module'; | import { WorkspaceMigrationRunnerModule } from 'src/workspace/workspace-migration-runner/workspace-migration-runner.module'; | ||||||
| import { WorkspaceMigrationModule } from 'src/metadata/workspace-migration/workspace-migration.module'; | import { WorkspaceMigrationModule } from 'src/metadata/workspace-migration/workspace-migration.module'; | ||||||
| import { metadataModuleFactory } from 'src/metadata/metadata.module-factory'; | import { metadataModuleFactory } from 'src/metadata/metadata.module-factory'; | ||||||
|  | import { ExceptionHandlerService } from 'src/integrations/exception-handler/exception-handler.service'; | ||||||
|  |  | ||||||
| import { DataSourceModule } from './data-source/data-source.module'; | import { DataSourceModule } from './data-source/data-source.module'; | ||||||
| import { FieldMetadataModule } from './field-metadata/field-metadata.module'; | import { FieldMetadataModule } from './field-metadata/field-metadata.module'; | ||||||
| @@ -15,7 +16,7 @@ import { RelationMetadataModule } from './relation-metadata/relation-metadata.mo | |||||||
|   imports: [ |   imports: [ | ||||||
|     GraphQLModule.forRootAsync<YogaDriverConfig>({ |     GraphQLModule.forRootAsync<YogaDriverConfig>({ | ||||||
|       driver: YogaDriver, |       driver: YogaDriver, | ||||||
|       imports: [], |       inject: [ExceptionHandlerService], | ||||||
|       useFactory: metadataModuleFactory, |       useFactory: metadataModuleFactory, | ||||||
|     }), |     }), | ||||||
|     DataSourceModule, |     DataSourceModule, | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| import { Injectable } from '@nestjs/common'; | import { BadRequestException, Injectable } from '@nestjs/common'; | ||||||
| import { InjectRepository } from '@nestjs/typeorm'; | import { InjectRepository } from '@nestjs/typeorm'; | ||||||
|  |  | ||||||
| import { FindManyOptions, FindOneOptions, Repository } from 'typeorm'; | import { FindManyOptions, FindOneOptions, Repository } from 'typeorm'; | ||||||
| @@ -59,7 +59,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt | |||||||
|       objectMetadataInput.nameSingular.toLowerCase() === |       objectMetadataInput.nameSingular.toLowerCase() === | ||||||
|       objectMetadataInput.namePlural.toLowerCase() |       objectMetadataInput.namePlural.toLowerCase() | ||||||
|     ) { |     ) { | ||||||
|       throw new Error( |       throw new BadRequestException( | ||||||
|         'The singular and plural name cannot be the same for an object', |         'The singular and plural name cannot be the same for an object', | ||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Weiko
					Weiko