-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Feature Description
I want to return actionable error messages to clients when an error occurs. In the case of an EntityNotFoundError being throw, I want to provide a formatted error with the entity type and a variation of the query/criteria.
The Solution
Expose the data passed to the EntityNotFoundError constructor.
export class EntityNotFoundError extends TypeORMError {
public readonly entityClass: EntityTarget<any>;
public readonly criteria: any;
constructor(entityClass: EntityTarget<any>, criteria: any) {
super();
this.entityClass = entityClass;
this.criteria = criteria;
this.message =
`Could not find any entity of type "${this.stringifyTarget(
entityClass,
)}" ` + `matching: ${this.stringifyCriteria(criteria)}`
}
...
}Considered Alternatives
Parsing the message is brittle, and not ideal.
Additional Context
No response
Relevant Database Driver(s)
- aurora-mysql
- aurora-postgres
- better-sqlite3
- cockroachdb
- cordova
- expo
- mongodb
- mysql
- nativescript
- oracle
- postgres
- react-native
- sap
- spanner
- sqlite
- sqlite-abstract
- sqljs
- sqlserver
Are you willing to resolve this issue by submitting a Pull Request?
Yes, I have the time, but I don't know how to start. I would need guidance.
iJhefe and aleks-devel