Here and below the "error" means any server response with code different from "Ok".
The issue with the existing implementation is that sometimes the error is handled and sometimes it's not. Therefore, sometimes it bubbles to the consumer code and sometimes that doesn't happen. That brings inconsistencies to the plugin's behavior.
Proposed solution: don't allow errors to ever bubble up to the consuming code. All the invocations of fetchDirections should be done inside try-catch blocks and, when necessary (currently there's only 1 such occasion), the error should be handled appropriately.
Also, updated the first example to display an error message (if any) using the plugin's events interface. To get an error, try e.g. to build a route from North America to Africa.
Here and below the "error" means any server response with
code
different from"Ok"
.The issue with the existing implementation is that sometimes the error is handled and sometimes it's not. Therefore, sometimes it bubbles to the consumer code and sometimes that doesn't happen. That brings inconsistencies to the plugin's behavior.
Proposed solution: don't allow errors to ever bubble up to the consuming code. All the invocations of
fetchDirections
should be done insidetry
-catch
blocks and, when necessary (currently there's only 1 such occasion), the error should be handled appropriately.Also, updated the first example to display an error message (if any) using the plugin's events interface. To get an error, try e.g. to build a route from North America to Africa.