Skip to content

Commit

Permalink
fix: fixing default error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Jan 22, 2024
1 parent 0a6f18e commit 3420448
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
21 changes: 16 additions & 5 deletions src/v0/destinations/marketo_bulk_upload/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const getAccessToken = async (config) =>
// sample response : {response: '[ENOTFOUND] :: DNS lookup failed', status: 400}
if (!isHttpStatusSuccess(accessTokenResponse.status)) {
throw new NetworkError(
'Could not retrieve authorisation token',
`Could not retrieve authorisation token due to error ${accessTokenResponse}`,
hydrateStatusForServer(accessTokenResponse.status, FETCH_ACCESS_TOKEN),
{
[tags.TAG_NAMES.ERROR_TYPE]: getDynamicErrorType(accessTokenResponse.status),
Expand Down Expand Up @@ -185,7 +185,10 @@ const getAccessToken = async (config) =>
}
return accessTokenResponse.response.access_token;
}
throw new AbortedError('Could not retrieve authorisation token', 400);
throw new AbortedError(

Check warning on line 188 in src/v0/destinations/marketo_bulk_upload/util.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/marketo_bulk_upload/util.js#L188

Added line #L188 was not covered by tests
`Could not retrieve authorisation token due to error ${accessTokenResponse}`,
400,
);
});

/**
Expand Down Expand Up @@ -254,14 +257,18 @@ const handleFetchJobStatusResponse = (resp, type) => {
if (!isHttpStatusSuccess(marketoReposnseStatus)) {
logger.info('[Network Error]:Failed during fetching job status', { marketoResponse, type });
throw new NetworkError(
'Unable to fetch job status',
`Unable to fetch job status: due to error ${marketoResponse}`,
hydrateStatusForServer(marketoReposnseStatus, 'During fetching job status'),
);
}

if (marketoResponse?.success === false) {
logger.info('[Application Error]Failed during fetching job status', { marketoResponse, type });
throw new RetryableError('Failure during fetching job status', 500, resp);
throw new RetryableError(

Check warning on line 267 in src/v0/destinations/marketo_bulk_upload/util.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/marketo_bulk_upload/util.js#L267

Added line #L267 was not covered by tests
`Failure during fetching job status due to error : ${marketoResponse}`,
500,
resp,
);
}

/*
Expand Down Expand Up @@ -394,7 +401,11 @@ const getFieldSchemaMap = async (accessToken, munchkinId) => {
fieldMap[field?.name] = field?.dataType;
});
} else {
throw new RetryableError('Failed to fetch Marketo Field Schema', 500, fieldSchemaMapping);
throw new RetryableError(

Check warning on line 404 in src/v0/destinations/marketo_bulk_upload/util.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/marketo_bulk_upload/util.js#L404

Added line #L404 was not covered by tests
`Failed to fetch Marketo Field Schema due to error ${fieldSchemaMapping}`,
500,
fieldSchemaMapping,
);
}
return fieldMap;
};
Expand Down
4 changes: 2 additions & 2 deletions test/__tests__/data/marketo_bulk_upload_jobStatus_output.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"statusCode": 400,
"error": "Unable to fetch job status"
"error": "Unable to fetch job status: due to error "
}
]
},
Expand All @@ -21,7 +21,7 @@
},
{
"statusCode": 400,
"error": "Unable to fetch job status"
"error": "Unable to fetch job status: due to error "
}
]
}
Expand Down

0 comments on commit 3420448

Please sign in to comment.