code;
message;
param;
- constructor(type, code, message, param) {
+ statusCode;
+ constructor(type, code, message, param, statusCode) {
this.type = type;
this.code = code;
this.message = message;
this.param = param;
+ this.statusCode = statusCode;
+ }
+ getValidationError() {
+ if (this.type !== "invalid_request_error" || this.statusCode !== 400) {
+ return undefined;
+ }
+ return new ValidationError(this.code, this.message, this.param);
}
}
exports.ApiError = ApiError;
+ class ValidationError {
+ code;
+ message;
+ param;
+ constructor(code, message, param) {
+ this.code = code;
+ this.message = message;
+ this.param = param;
+ }
+ }
});
typeof json.code === "string" &&
typeof json.message === "string" &&
typeof json.param === "string") {
- return apiResultFromError(new Error_1.ApiError(json.type, json.code, json.message, json.param));
+ return apiResultFromError(new Error_1.ApiError(json.type, json.code, json.message, json.param, response.status));
}
throw e;
}