fix(?): don't parse data twice
This commit is contained in:
parent
33ee82efa4
commit
58e446d999
@ -12,14 +12,14 @@ interface ApiError {
|
|||||||
data?: any,
|
data?: any,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parse(code: number, data?: string): ApiError {
|
export function parse(code: number, data?: any): ApiError {
|
||||||
var type = ErrorType[ErrorType[code]] ?? ErrorType.Unknown;
|
var type = ErrorType[ErrorType[code]] ?? ErrorType.Unknown;
|
||||||
if (code >= 500) type = ErrorType.InternalServerError;
|
if (code >= 500) type = ErrorType.InternalServerError;
|
||||||
|
|
||||||
var err: ApiError = { code, type };
|
var err: ApiError = { code, type };
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
var d = JSON.parse(data);
|
var d = data;
|
||||||
err.message = d.message;
|
err.message = d.message;
|
||||||
err.data = d;
|
err.data = d;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user