/// <summary> /// Handle map loading error /// </summary> /// <param name="errorArgs"><see cref="MapLoadErrorArgs"/> that help identify the issue</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when error type (<see cref="ErrorArgs.DetailedErrorEnum"/>) /// is not recognized</exception> private static void OnMapLoadErrorCallback(MapLoadErrorArgs errorArgs) { switch (errorArgs.DetailedErrorCode) { case ErrorArgs.DetailedErrorEnum.None: Instance.Hide(); break; case ErrorArgs.DetailedErrorEnum.UnsupportedClientVersion: Instance.ExposeMessage($"The {Application.version} version of the GUT Guide is unsupported"); break; case ErrorArgs.DetailedErrorEnum.ClientError: Instance.ExposeMessage("The request to the API succeeded, but an error occurred on the client"); break; case ErrorArgs.DetailedErrorEnum.NetworkError: Instance.ExposeMessage(Application.internetReachability == NetworkReachability.NotReachable ? "GUT Guide must have internet access in order to run" : $"GUT Guide was not able to get an HTTP response after {errorArgs.Attempts} attempts"); break; case ErrorArgs.DetailedErrorEnum.InvalidRequest: Instance.ExposeMessage("The request sent from the SDK to the API was invalid"); break; case ErrorArgs.DetailedErrorEnum.PermissionDenied: Instance.ExposeMessage("The API key does not have permission to make requests"); break; case ErrorArgs.DetailedErrorEnum.NotFound: Instance.ExposeMessage("Nothing exists at the URL that you used"); break; case ErrorArgs.DetailedErrorEnum.OutOfQuota: Instance.ExposeMessage("You exceeded the quota for the API"); break; case ErrorArgs.DetailedErrorEnum.ServerError: Instance.ExposeMessage("An error occurred at the API server"); break; case ErrorArgs.DetailedErrorEnum.Unknown: Instance.ExposeMessage("Unknown error occurred. Check app log for details."); Debug.Log(errorArgs.Message); break; default: throw new ArgumentOutOfRangeException(nameof(errorArgs.DetailedErrorCode), errorArgs.DetailedErrorCode, "Unrecognized error type!"); } }
/// <summary> /// Shows an error image in the centre of the Bounds contained in the given /// <see cref="MapLoadErrorArgs"/>. /// </summary> /// <param name="args"> /// The <see cref="MapLoadErrorArgs"/> from the <see cref="MapEvents.LoadError"/> event. /// </param> private void OnMapLoadError(MapLoadErrorArgs args) { Bounds bounds = args.GetBounds(MapsService.Coords); foreach (GameObject errorImage in ErrorImages) { // If there is already an error image in the area that failed to load, don't show another one. if (bounds.Contains(errorImage.transform.position)) { return; } } GameObject newImage = Instantiate(ErrorIndicator, bounds.center, new Quaternion()); ErrorImages.AddLast(newImage); // Ensure the FloatingOriginUpdater knows about all the error images so they can be // repositioned if necessary. GetComponent <FloatingOriginUpdater>().SetAdditionalGameObjects(ErrorImages); }