bmlt-enabled / bmlt-root-server

This is the Main Root Server Repo for the Basic Meeting List Toolbox
MIT License
13 stars 14 forks source link

Properly handle miscellaneous errors in the ApiClientWrapper #1000

Open alanb2718 opened 3 months ago

alanb2718 commented 3 months ago

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 commented 3 months ago

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