Skip to content
This repository has been archived by the owner on Mar 31, 2021. It is now read-only.

update tfl request error message handling #311

Conversation

liamgarrison
Copy link
Contributor

Fixes #294

@@ -10,11 +10,13 @@ async function request(url, opts) {
try {
const response = await fetch(url, opts);
if (!response.ok) {
throw new Error(response);
// This will be caught by the catch block and recaught
throw new Error(response.statusText);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you'd want to throw an HTTPError and have the second argument be the http status code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've simplified it and made it more like the other integrations.

@corradio corradio merged commit 42312c6 into electricitymaps:master Jan 24, 2020
@corradio
Copy link
Member

corradio commented Jan 24, 2020 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TFL HTTP error reports [object Object] instead of String
2 participants