1 (edited by mikli1 2024-06-28 09:31:51)

Topic: Could not find token at index 0 in NextTokenCore

OpenRouteService is unavailable/unstable today and calling

public static OnlineMapsOpenRouteServiceGeocodingResult GetResult(string response)

throws an exception.

How can I handle it the best way? The Deserialize method should check the json schema before trying to parse tokens from it.

Full stack trace:

Exception: Could not find token at index 0. 
OnlineMapsJSON.NextTokenCore () (at Assets/Infinity Code/Online maps/Scripts/JSON/OnlineMapsJSON.cs:314)
OnlineMapsJSON.LookAhead () (at Assets/Infinity Code/Online maps/Scripts/JSON/OnlineMapsJSON.cs:199)
OnlineMapsJSON.ParseValueDirect () (at Assets/Infinity Code/Online maps/Scripts/JSON/OnlineMapsJSON.cs:673)
OnlineMapsJSON.ParseDirect (System.String json) (at Assets/Infinity Code/Online maps/Scripts/JSON/OnlineMapsJSON.cs:336)
OnlineMapsJSON.Deserialize[T] (System.String json) (at Assets/Infinity Code/Online maps/Scripts/JSON/OnlineMapsJSON.cs:38)
OnlineMapsOpenRouteServiceGeocode.GetResult (System.String response) (at Assets/Infinity Code/Online maps/Scripts/WebServices/OnlineMapsOpenRouteServiceGeocode.cs:68)
RenderPoiPopupSystem.OnGeocodingComplete (System.String response) (at Assets/Fenix/Scripts/GUI/Systems/RenderPoiPopupSystem.cs:234)
OnlineMapsTextWebService.OnRequestComplete (OnlineMapsWWW www) (at Assets/Infinity Code/Online maps/Scripts/WebServices/Base/OnlineMapsTextWebService.cs:69)
OnlineMapsWWW.Finish () (at Assets/Infinity Code/Online maps/Scripts/Core/OnlineMapsWWW.cs:373)
OnlineMapsWWW+<WaitResponse>d__61.MoveNext () (at Assets/Infinity Code/Online maps/Scripts/Core/OnlineMapsWWW.cs:526)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <55fbbbd17b724c15b6abe8c1a3e3289c>:0)

json is equal to:

HTTP/1.1 502 Bad Gateway

but Deserialize method expects it to look like this:

{
  "session": "AJVsH2wdunNFKvFLUhPBXzimpjU4JRrRN5fCYqV57jKTq2UEtOZcx8JamlCEElbYVd_bqWdJzQxz_G57-Bj965QMVUpKPNwbrQGA7TyzcRrydyYhwpSYq7WLg6rGO_59B6ZrXlDLi5H6uuevPTAOmfryJe6q65ot0JHcUQCrkHDkielIAujzm-wloxzO-dmQQuvXahdmppHqKVU",
  "expiry": "1720776256",
  "tileWidth": 256,
  "imageFormat": "png",
  "tileHeight": 256
}

Re: Could not find token at index 0 in NextTokenCore

Hello.

Errors 5xx are server-side errors.
I just checked and ORS is working correctly now, so most likely they have already fixed the server issue.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.