# Class GoogleApiException (1.73.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.73.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.GoogleApiException)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.GoogleApiException)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.GoogleApiException)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.GoogleApiException)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.GoogleApiException)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.GoogleApiException)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.GoogleApiException)

    public class GoogleApiException : Exception, ISerializable

Represents an exception thrown by an API Service.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> [Exception](https://learn.microsoft.com/dotnet/api/system.exception) \> GoogleApiException

## Implements

[ISerializable](https://learn.microsoft.com/dotnet/api/system.runtime.serialization.iserializable)

## Inherited Members

[Exception.GetBaseException()](https://learn.microsoft.com/dotnet/api/system.exception.getbaseexception) [Exception.GetObjectData(SerializationInfo, StreamingContext)](https://learn.microsoft.com/dotnet/api/system.exception.getobjectdata) [Exception.GetType()](https://learn.microsoft.com/dotnet/api/system.exception.gettype) [Exception.Data](https://learn.microsoft.com/dotnet/api/system.exception.data) [Exception.HelpLink](https://learn.microsoft.com/dotnet/api/system.exception.helplink) [Exception.HResult](https://learn.microsoft.com/dotnet/api/system.exception.hresult) [Exception.InnerException](https://learn.microsoft.com/dotnet/api/system.exception.innerexception) [Exception.Source](https://learn.microsoft.com/dotnet/api/system.exception.source) [Exception.StackTrace](https://learn.microsoft.com/dotnet/api/system.exception.stacktrace) [Exception.TargetSite](https://learn.microsoft.com/dotnet/api/system.exception.targetsite) [Exception.SerializeObjectState](https://learn.microsoft.com/dotnet/api/system.exception.serializeobjectstate) [object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals)

## Namespace

[Google](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google)

## Assembly

Google.Apis.Core.dll

## Constructors

### GoogleApiException(string)

    public GoogleApiException(string serviceName)

Creates an API Service exception with no message.

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` |

**Remarks** [Message](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.GoogleApiException#Google_GoogleApiException_Message) may still contain useful information if the
[Error](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.GoogleApiException#Google_GoogleApiException_Error) and/or [HttpStatusCode](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.GoogleApiException#Google_GoogleApiException_HttpStatusCode) properties are set.

### GoogleApiException(string, string)

    public GoogleApiException(string serviceName, string message)

Creates an API Service exception.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `message` | `https://learn.microsoft.com/dotnet/api/system.string` |

### GoogleApiException(string, string, Exception)

    public GoogleApiException(string serviceName, string message, Exception inner)

Creates an API Service exception.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `serviceName` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `message` | `https://learn.microsoft.com/dotnet/api/system.string` |
| `inner` | `https://learn.microsoft.com/dotnet/api/system.exception` |

## Properties

### Error

    public RequestError Error { get; set; }

The Error which was returned from the server, or `null` if unavailable.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Requests.RequestError` |   |

### HttpStatusCode

    public HttpStatusCode HttpStatusCode { get; set; }

The HTTP status code which was returned along with this error, or 0 if unavailable.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.net.httpstatuscode` |   |

### Message

    public override string Message { get; }

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

**Overrides** [Exception.Message](https://learn.microsoft.com/dotnet/api/system.exception.message)

### ServiceName

    public string ServiceName { get; }

Gets the service name which related to this exception.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` |   |

## Methods

### ToString()

    public override string ToString()

Returns a summary of this exception.

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.string` | A summary of this exception. |

**Overrides** [Exception.ToString()](https://learn.microsoft.com/dotnet/api/system.exception.tostring)

## Extension Method

[Utilities.ThrowIfNull\<T\>(T, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)