All Downloads are FREE. Search and download functionalities are using the official Maven repository.

csharp.libraries.unityWebRequest.UnexpectedResponseException.mustache Maven / Gradle / Ivy

There is a newer version: 7.6.0
Show newest version
{{>partial_header}}

using System;
using UnityEngine.Networking;

namespace {{packageName}}.Client
{
    // Thrown when a backend doesn't return an expected response based on the expected type
    // of the response data.
    public class UnexpectedResponseException : Exception
    {
        public int ErrorCode { get; private set; }

        // NOTE: Cannot keep reference to the request since it will be disposed.
        public UnexpectedResponseException(UnityWebRequest request, System.Type type, string extra = "")
            : base(CreateMessage(request, type, extra))
        {
            ErrorCode = (int)request.responseCode;
        }

        private static string CreateMessage(UnityWebRequest request, System.Type type, string extra)
        {
            return $"httpcode={request.responseCode}, expected {type.Name} but got data: {extra}";
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy