Handling errors returned from the server

Each of the Targomo web services take a success and error callback function as parameters. Since we also support older version if Internet Explorer we issue all our requests via JSONP. Unfortuneatly this makes it very hard to catch server side errors or exceptions. We walkaround this limitation by returning a 200 Request Ok and return a JSON Object that looks like this: { data : [], status : "", message : "" }. We can the evaluate the given errors at least after the timeout defined for the jQuery.ajax() call. The currently possbile error codes are:


This exceptions happens if the whole Targomo web service is not available. This might be due to a service restart/update or a complete outage. We are closely monitoring our service availablity, so should you receive this message for longer than a short period of minutes and you are sure you configured the service url correct, please don't hesitate to contact us.


This exception is thrown if there is no route between a given source and target point. This can happen, if for example the target point is on an island and therefore no direct connection to the main network exists.


This exception happens if the travel time between a given source and target point exceeds the server side limitation of 12 hours.


This exception is thrown if the configuration of each service is incorrect, for example if a travel type that is not supported or a transit date not covered by the server is given.


The service connects the given source and target points to the underlying OSM network. Therefore we calculate the closest edge to the given point that matches the given travel type. If we can't find such an edge this exception is returned.

The code should produce the following error message:

service-not-available: The routing service is currently not available, please try again later.

Handling errors returned from the server

Intercept and interpret error messages from Targomo

GET YOUR FREE API KEY to use this example
open in new tab
show code