-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmindeeError.ts
More file actions
71 lines (62 loc) · 1.61 KB
/
mindeeError.ts
File metadata and controls
71 lines (62 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { ErrorDetails, ErrorResponse, ErrorItem } from "../parsing/v2";
/**
* Main Mindee Error custom class.
*/
export class MindeeError extends Error {
constructor(message: string) {
super(message);
this.name = "MindeeError";
}
}
/**
* Custom Mindee error relating to improper inputs.
*/
export class MindeeInputError extends MindeeError {
constructor(message: string) {
super(message);
this.name = "MindeeInputError";
}
}
/**
* Custom Mindee error relating to improper mimetypes in inputs.
*/
export class MindeeMimeTypeError extends MindeeError {
constructor(message: string) {
super(message);
this.name = "MindeeMimeTypeError";
}
}
export class MindeeImageError extends MindeeError {
constructor(message: string) {
super(message);
this.name = "MindeeImageError";
}
}
export class MindeePdfError extends MindeeError {
constructor(message: string) {
super(message);
this.name = "MindeePdfError";
}
}
export class MindeeApiV2Error extends MindeeError {
constructor(message: string) {
super(message);
this.name = "MindeeApiV2Error";
}
}
export class MindeeHttpErrorV2 extends MindeeError implements ErrorDetails {
public status: number;
public detail: string;
public title: string;
public code: string;
public errors: ErrorItem[];
constructor(error: ErrorResponse) {
super(`HTTP ${error.status} - ${error.title} :: ${error.code} - ${error.detail}`);
this.status = error.status;
this.detail = error.detail;
this.title = error.title;
this.code = error.code;
this.errors = error.errors;
this.name = "MindeeHttpErrorV2";
}
}