fix(core): Better errors for common status codes fix

This commit is contained in:
Michael Kret 2023-05-03 12:45:44 +03:00 committed by GitHub
parent 570790ed0c
commit 700cc39cbc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View file

@ -316,12 +316,17 @@ export class NodeApiError extends NodeError {
(error?.reason as IDataObject)?.description) as string;
}
if (!httpCode && !message && error.status === 'rejected') {
if (
!httpCode &&
!message &&
this.message &&
this.message.toUpperCase().includes('ECONNREFUSED')
) {
httpCode = 'ECONNREFUSED';
const originalMessage = this.message;
if (!description && originalMessage) {
this.description = `${originalMessage} ${this.description ?? ''}`;
if (!description) {
this.description = `${originalMessage}; ${this.description ?? ''}`;
}
}

View file

@ -61,7 +61,6 @@ describe('NodeErrors tests', () => {
it('should return default message for ECONNREFUSED', () => {
const nodeApiError = new NodeApiError(node, {
status: 'rejected',
message: 'ECONNREFUSED',
});