-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Gracefully handle non-English postcodes #244
feat: Gracefully handle non-English postcodes #244
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
case "ITL3_NOT_FOUND": | ||
case "INSUFFICIENT_PRICES_PAID_DATA": | ||
methods.setError( | ||
"housePostcode", | ||
{ message: | ||
"Insufficient data for this postcode. Please try again with a different postcode" | ||
} | ||
); | ||
break; |
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.
We could handle these two cases differently, but right now this is a little white-lie about non-English postcodes.
07b1e35
to
0b59b57
Compare
app/data/itlRepo.ts
Outdated
|
||
throw new APIError({ | ||
status: 500, | ||
message: `Data error: Unable get get itl3 for postcode district ${postcodeDistrict}`, |
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.
minor typo 'get get'
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.
Great catch - fixed in ecd1570
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.
That's very elegant! If I get it correctly:
- A new object
APIErrorCode
is created. This extends the currentError
class APIErrorCode
can be of 3 types:| "ITL3_NOT_FOUND" | "INSUFFICIENT_PRICES_PAID_DATA" | "UNHANDLED_EXCEPTION"
;- If the Error code type 1 or 2 is returned by the API, we trigger the form validation with message "Insufficient data for this postcode. Please try again with a different postcode"
Otherwise we triggerconsole.log
with the default error message from the generalError
class. I assume errors such as : failing to connect to the database or similar will follow in this category, is that correct?
@gabrielegranello Perfectly correct! In future it would be nice to handle unhandled erorrs a bit better (e.g. logging the error to an eternal monitoring service, displaying a "try again" status to the user), but for now we just return the user the specific errors we care most about and throw unhandled errors. |
b364c36
to
2a26cf3
Compare
ecd1570
to
164da34
Compare
* feat: Query new `PricePaidSummary` model * test: Update test cases * feat: Gracefully handle non-English postcodes (#244) * feat: Error handling for non-English postcodes * fix: Typos * test: Fix tests for new API errors
What does this PR do?
APIError
classScreen.Recording.2025-01-08.at.16.17.44.mov