2024-03-18 13:58:05 +01:00
|
|
|
import { type ApiErrorSchema, UnleashError } from './unleash-error';
|
2023-09-04 13:53:33 +02:00
|
|
|
|
2023-09-06 12:20:10 +02:00
|
|
|
class PatternError extends UnleashError {
|
|
|
|
statusCode = 400;
|
2023-09-04 13:53:33 +02:00
|
|
|
|
2023-09-06 12:20:10 +02:00
|
|
|
details?: { message: string }[];
|
|
|
|
|
|
|
|
constructor(message: string, details?: string[]) {
|
2023-09-04 13:53:33 +02:00
|
|
|
super(message);
|
2023-09-06 12:20:10 +02:00
|
|
|
this.details = details?.map((description) => ({
|
|
|
|
message: description,
|
|
|
|
}));
|
2023-09-04 13:53:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
toJSON(): ApiErrorSchema {
|
|
|
|
return {
|
|
|
|
...super.toJSON(),
|
2023-09-06 12:20:10 +02:00
|
|
|
details: this.details,
|
2023-09-04 13:53:33 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PatternError;
|