typeorm APIs
- Column
- Entity
- PrimaryGeneratedColumn
- createConnection
- CreateDateColumn
- ManyToOne
- OneToMany
- UpdateDateColumn
- Repository
- JoinColumn
- QueryRunner
- Connection
- MigrationInterface
- getRepository
- getConnection
- BaseEntity
- OneToOne
- JoinTable
- PrimaryColumn
- Index
- ManyToMany
- Table
- EntityRepository
- SelectQueryBuilder
- In
- ConnectionOptions
- BeforeInsert
- Not
- getManager
- Brackets
- Unique
- TableColumn
- MoreThan
- TableForeignKey
- BeforeUpdate
- IsNull
- EntityManager
- ObjectType
- ObjectIdColumn
- RelationId
- getCustomRepository
- FindOneOptions
- MongoRepository
- ObjectID
- getConnectionManager
- DeleteDateColumn
- FindConditions
- MoreThanOrEqual
- getMongoRepository
- Generated
- DeepPartial
- LessThan
- ValueTransformer
- LessThanOrEqual
- FindManyOptions
- Like
- EntitySchema
- Raw
- VersionColumn
- AfterLoad
- DeleteResult
- EventSubscriber
- EntitySubscriberInterface
- InsertEvent
- createQueryBuilder
- createConnections
- getConnectionOptions
- DefaultNamingStrategy
- ObjectLiteral
- ILike
- Between
- Logger
- TreeRepository
- DataSource
- TableIndex
- WhereExpressionBuilder
- useContainer
- EntityTarget
- SaveOptions
- FindOperator
- ConnectionOptionsReader
- EntityMetadata
- RemoveEvent
- InsertResult
- UpdateEvent
- TreeChildren
- TreeParent
- DeleteQueryBuilder
- ChildEntity
- WhereExpression
- ViewEntity
- getMetadataArgsStorage
- OrderByCondition
- AfterInsert
- AfterUpdate
- BeforeRemove
- Timestamp
- QueryFailedError
- UpdateResult
- Equal
- UpdateQueryBuilder
- ColumnType
- ColumnOptions
- InstanceChecker
- DataSourceOptions
Other Related APIs
typeorm#QueryFailedError TypeScript Examples
The following examples show how to use
typeorm#QueryFailedError.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: query-failed.filter.ts From bank-server with MIT License | 6 votes |
@Catch(QueryFailedError)
export class QueryFailedFilter implements ExceptionFilter {
constructor(public reflector: Reflector) {}
catch(exception: any, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const errorMessage = ConstraintErrors[exception.constraint];
const status =
exception.constraint && exception.constraint.startsWith('UQ')
? HttpStatus.CONFLICT
: HttpStatus.INTERNAL_SERVER_ERROR;
response.status(status).json({
statusCode: status,
error: STATUS_CODES[status],
message: errorMessage,
});
}
}