Skip to content
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

Properly handle miscellaneous errors in the ApiClientWrapper #1000

Open
alanb2718 opened this issue Aug 3, 2024 · 1 comment
Open

Properly handle miscellaneous errors in the ApiClientWrapper #1000

alanb2718 opened this issue Aug 3, 2024 · 1 comment

Comments

@alanb2718
Copy link
Collaborator

The handleErrors method in the ApiClientWrapper has a line at the end of the method for errors that weren't handled earlier:
return console.log('TODO show error dialog', error.message);
This is https://github.com/bmlt-enabled/bmlt-root-server/blob/main/src/resources/js/lib/RootServerApi.ts#L291

Change this to handle the error properly and raise an exception. Right now there are a couple of unit test bugs (#995 and #999) that were difficult to notice because the test just printed an error message rather than failing.

@alanb2718
Copy link
Collaborator Author

I tried replacing this line
return console.log('TODO show error dialog', error.message);

with
throw new Error('unhandled exception: ' + error.message);

Then the unit tests fail as expected. I'm not sure if this is the best way to handle this case, but it does at least catch the error properly.

Also, setting a breakpoint and inspecting the error turns this up:
cause = TypeError: Invalid URL: //api/v1/auth/token\n

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

No branches or pull requests

1 participant