Table of Contents

Class VonageHttpRequestException

Namespace
Vonage.Common.Exceptions
Assembly
Vonage.dll

Represents an issue when processing an HttpRequest.

public class VonageHttpRequestException : HttpRequestException, ISerializable
Inheritance
VonageHttpRequestException
Implements
Inherited Members

Examples

throw new VonageHttpRequestException("Request failed")
{
    HttpStatusCode = HttpStatusCode.BadRequest,
    Json = "{\"error\":\"invalid_request\"}"
};

Constructors

VonageHttpRequestException(Exception)

Creates a VonageHttpRequestException.

public VonageHttpRequestException(Exception inner)

Parameters

inner Exception

The inner exception.

Examples

try { /* http operation */ }
catch (Exception ex)
{
    throw new VonageHttpRequestException(ex);
}

VonageHttpRequestException(string)

Creates a VonageHttpRequestException.

public VonageHttpRequestException(string message)

Parameters

message string

The exception message.

Examples

throw new VonageHttpRequestException("Server returned an error");

Properties

HttpStatusCode

The response status code.

public HttpStatusCode HttpStatusCode { get; init; }

Property Value

HttpStatusCode

Examples

catch (VonageHttpRequestException ex)
{
    if (ex.HttpStatusCode == HttpStatusCode.NotFound) { /* handle 404 */ }
}

Json

The response body content.

public string Json { get; init; }

Property Value

string

Examples

catch (VonageHttpRequestException ex)
{
    Console.WriteLine($"Error response: {ex.Json}");
}