-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds an error catch for null responses #501
Conversation
utils/queryApiGateway.ts
Outdated
// This is the response for a bad UniqueNumber, or a UniqueNumber without a claim | ||
const nullResponseShort = { | ||
claimDetails: null, | ||
hasCertificationWeeksAvailable: false, | ||
hasPendingWeeks: false, | ||
pendingDetermination: null, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you include this, you are in effect making it so that this is unreachable:
ui-claim-tracker/utils/queryApiGateway.ts
Lines 183 to 190 in d79ff60
if (apiData?.uniqueNumber !== uniqueNumber) { | |
const mismatchError = new Error( | |
`Mismatched API response and Header unique number (${apiData.uniqueNumber || 'null'} and ${uniqueNumber})`, | |
) | |
const logger: Logger = Logger.getInstance() | |
logger.log('error', mismatchError, 'Unexpected API gateway response') | |
throw mismatchError | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Therefore, I think you should either not include the nullResponseShort
or handle the mismatchError first before you handle the new null response error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh interesting - I was considering mismatched UniqueNumber
when the API gave us a null
to be incidentally catching the null
response case, and that this is a more accurate error for that situation. That is still reachable if we get back the different unique number, or get back some claim data but a null unique number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting. I see what you mean. This sounds good to me!
utils/queryApiGateway.ts
Outdated
assert.notDeepStrictEqual(response, nullResponseShort, 'Response is null') | ||
assert.notDeepStrictEqual(response, nullResponseLong, 'Response is null') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is neat
utils/queryApiGateway.ts
Outdated
const nullResponseLong = { | ||
claimDetails: { | ||
programType: '', | ||
benefitYearStartDate: null, | ||
benefitYearEndDate: null, | ||
claimBalance: null, | ||
weeklyBenefitAmount: null, | ||
lastPaymentIssued: null, | ||
lastPaymentAmount: null, | ||
monetaryStatus: '', | ||
}, | ||
hasCertificationWeeksAvailable: false, | ||
hasPendingWeeks: false, | ||
pendingDetermination: [], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor nit. LGTM!
Co-authored-by: Rocket <[email protected]>
Checks if the API has responded with what we consider a null response, and logs that case clearly.
===
Resolves #480
main