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