More debug information in timeout and fetch errors (#678).

This commit is contained in:
Richard Moore 2020-06-12 04:41:07 -04:00
parent 5e7d28b19b
commit 693094e97c
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651

View File

@ -122,7 +122,12 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
if (timer == null) { return; }
timer = null;
reject(logger.makeError("timeout", Logger.errors.TIMEOUT, { timeout: timeout }));
reject(logger.makeError("timeout", Logger.errors.TIMEOUT, {
requestBody: (options.body || null),
requestMethod: options.method,
timeout: timeout,
url: url
}));
}, timeout);
}
});
@ -146,6 +151,8 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
if (response == null) {
runningTimeout.cancel();
logger.throwError("missing response", Logger.errors.SERVER_ERROR, {
requestBody: (options.body || null),
requestMethod: options.method,
serverError: error,
url: url
});
@ -164,6 +171,8 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
status: response.statusCode,
headers: response.headers,
body: body,
requestBody: (options.body || null),
requestMethod: options.method,
url: url
});
}
@ -178,6 +187,8 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
logger.throwError("invalid JSON", Logger.errors.SERVER_ERROR, {
body: body,
error: error,
requestBody: (options.body || null),
requestMethod: options.method,
url: url
});
}
@ -189,7 +200,10 @@ export function fetchJson(connection: string | ConnectionInfo, json?: string, pr
} catch (error) {
logger.throwError("processing response error", Logger.errors.SERVER_ERROR, {
body: json,
error: error
error: error,
requestBody: (options.body || null),
requestMethod: options.method,
url: url
});
}
}