Skip to content

Commit

Permalink
Use existing ErrorDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
hsubox76 committed May 22, 2024
1 parent dd14db8 commit 518ea36
Show file tree
Hide file tree
Showing 20 changed files with 150 additions and 49 deletions.
20 changes: 0 additions & 20 deletions docs/reference/files/generative-ai.errordetail.md

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetail](./generative-ai.errordetail.md) &gt; ["@type"](./generative-ai.errordetail.__type_.md)
[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; ["@type"](./generative-ai.errordetails.__type_.md)

## ErrorDetail."@type" property
## ErrorDetails."@type" property

**Signature:**

Expand Down
11 changes: 11 additions & 0 deletions docs/reference/files/generative-ai.errordetails.domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [domain](./generative-ai.errordetails.domain.md)

## ErrorDetails.domain property

**Signature:**

```typescript
domain?: string;
```
23 changes: 23 additions & 0 deletions docs/reference/files/generative-ai.errordetails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md)

## ErrorDetails interface

Details object that may be included in an error response.

**Signature:**

```typescript
export interface ErrorDetails
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| ["@type"?](./generative-ai.errordetails.__type_.md) | | string | _(Optional)_ |
| [domain?](./generative-ai.errordetails.domain.md) | | string | _(Optional)_ |
| [metadata?](./generative-ai.errordetails.metadata.md) | | Record&lt;string, unknown&gt; | _(Optional)_ |
| [reason?](./generative-ai.errordetails.reason.md) | | string | _(Optional)_ |

11 changes: 11 additions & 0 deletions docs/reference/files/generative-ai.errordetails.metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [metadata](./generative-ai.errordetails.metadata.md)

## ErrorDetails.metadata property

**Signature:**

```typescript
metadata?: Record<string, unknown>;
```
11 changes: 11 additions & 0 deletions docs/reference/files/generative-ai.errordetails.reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [reason](./generative-ai.errordetails.reason.md)

## ErrorDetails.reason property

**Signature:**

```typescript
reason?: string;
```
2 changes: 1 addition & 1 deletion docs/reference/files/generative-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

| Interface | Description |
| --- | --- |
| [ErrorDetail](./generative-ai.errordetail.md) | Optional additional error details. |
| [ErrorDetails](./generative-ai.errordetails.md) | Details object that may be included in an error response. |
| [FileMetadata](./generative-ai.filemetadata.md) | Metadata to provide alongside a file upload |
| [FileMetadataResponse](./generative-ai.filemetadataresponse.md) | File metadata response from server. |
| [ListFilesResponse](./generative-ai.listfilesresponse.md) | Response from calling [GoogleAIFileManager.listFiles()](./generative-ai.googleaifilemanager.listfiles.md) |
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/files/generative-ai.rpcstatus.details.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ A list of messages that carry the error details.
**Signature:**

```typescript
details?: ErrorDetail[];
details?: ErrorDetails[];
```
2 changes: 1 addition & 1 deletion docs/reference/files/generative-ai.rpcstatus.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export interface RpcStatus
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [code](./generative-ai.rpcstatus.code.md) | | number | Error status code |
| [details?](./generative-ai.rpcstatus.details.md) | | [ErrorDetail](./generative-ai.errordetail.md)<!-- -->\[\] | _(Optional)_ A list of messages that carry the error details. |
| [details?](./generative-ai.rpcstatus.details.md) | | [ErrorDetails](./generative-ai.errordetails.md)<!-- -->\[\] | _(Optional)_ A list of messages that carry the error details. |
| [message](./generative-ai.rpcstatus.message.md) | | string | A developer-facing error message. |

11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.errordetails.__type_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; ["@type"](./generative-ai.errordetails.__type_.md)

## ErrorDetails."@type" property

**Signature:**

```typescript
"@type"?: string;
```
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.errordetails.domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [domain](./generative-ai.errordetails.domain.md)

## ErrorDetails.domain property

**Signature:**

```typescript
domain?: string;
```
23 changes: 23 additions & 0 deletions docs/reference/main/generative-ai.errordetails.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md)

## ErrorDetails interface

Details object that may be included in an error response.

**Signature:**

```typescript
export interface ErrorDetails
```

## Properties

| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| ["@type"?](./generative-ai.errordetails.__type_.md) | | string | _(Optional)_ |
| [domain?](./generative-ai.errordetails.domain.md) | | string | _(Optional)_ |
| [metadata?](./generative-ai.errordetails.metadata.md) | | Record&lt;string, unknown&gt; | _(Optional)_ |
| [reason?](./generative-ai.errordetails.reason.md) | | string | _(Optional)_ |

11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.errordetails.metadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [metadata](./generative-ai.errordetails.metadata.md)

## ErrorDetails.metadata property

**Signature:**

```typescript
metadata?: Record<string, unknown>;
```
11 changes: 11 additions & 0 deletions docs/reference/main/generative-ai.errordetails.reason.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@google/generative-ai](./generative-ai.md) &gt; [ErrorDetails](./generative-ai.errordetails.md) &gt; [reason](./generative-ai.errordetails.reason.md)

## ErrorDetails.reason property

**Signature:**

```typescript
reason?: string;
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ constructor(message: string, status?: number, statusText?: string, errorDetails?
| message | string | |
| status | number | _(Optional)_ |
| statusText | string | _(Optional)_ |
| errorDetails | ErrorDetails\[\] | _(Optional)_ |
| errorDetails | [ErrorDetails](./generative-ai.errordetails.md)<!-- -->\[\] | _(Optional)_ |

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export declare class GoogleGenerativeAIFetchError extends GoogleGenerativeAIErro
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [errorDetails?](./generative-ai.googlegenerativeaifetcherror.errordetails.md) | | ErrorDetails\[\] | _(Optional)_ |
| [errorDetails?](./generative-ai.googlegenerativeaifetcherror.errordetails.md) | | [ErrorDetails](./generative-ai.errordetails.md)<!-- -->\[\] | _(Optional)_ |
| [status?](./generative-ai.googlegenerativeaifetcherror.status.md) | | number | _(Optional)_ |
| [statusText?](./generative-ai.googlegenerativeaifetcherror.statustext.md) | | string | _(Optional)_ |
1 change: 1 addition & 0 deletions docs/reference/main/generative-ai.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
| [EmbedContentRequest](./generative-ai.embedcontentrequest.md) | Params for calling [GenerativeModel.embedContent()](./generative-ai.generativemodel.embedcontent.md) |
| [EmbedContentResponse](./generative-ai.embedcontentresponse.md) | Response from calling [GenerativeModel.embedContent()](./generative-ai.generativemodel.embedcontent.md)<!-- -->. |
| [EnhancedGenerateContentResponse](./generative-ai.enhancedgeneratecontentresponse.md) | Response object wrapped with helper methods. |
| [ErrorDetails](./generative-ai.errordetails.md) | Details object that may be included in an error response. |
| [FileData](./generative-ai.filedata.md) | Data pointing to a file uploaded with the Files API. |
| [FileDataPart](./generative-ai.filedatapart.md) | Content part interface if the part represents FunctionResponse. |
| [FunctionCall](./generative-ai.functioncall.md) | A predicted \[FunctionCall\] returned from the model that contains a string representing the \[FunctionDeclaration.name\] and a structured JSON object containing the parameters and their values. |
Expand Down
14 changes: 2 additions & 12 deletions packages/main/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

import { ErrorDetails } from "../types";

/**
* Basic error type for this SDK.
* @public
Expand Down Expand Up @@ -62,15 +64,3 @@ export class GoogleGenerativeAIFetchError extends GoogleGenerativeAIError {
* @public
*/
export class GoogleGenerativeAIRequestInputError extends GoogleGenerativeAIError {}

/**
* Details object that may be included in an error response.
* @public
*/
interface ErrorDetails {
"@type"?: string;
reason?: string;
domain?: string;
metadata?: Record<string, unknown>;
[key: string]: unknown;
}
15 changes: 5 additions & 10 deletions packages/main/src/files/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* limitations under the License.
*/

import { ErrorDetails } from "../../types";

export { ErrorDetails };

/**
* Params to pass to {@link GoogleAIFileManager.listFiles}
* @public
Expand Down Expand Up @@ -107,16 +111,7 @@ export interface RpcStatus {
/**
* A list of messages that carry the error details.
*/
details?: ErrorDetail[];
}

/**
* Optional additional error details.
* @public
*/
export interface ErrorDetail {
"@type"?: string;
[key: string]: unknown;
details?: ErrorDetails[];
}

/**
Expand Down
12 changes: 12 additions & 0 deletions packages/main/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,15 @@ export interface BatchEmbedContentsResponse {
export interface ContentEmbedding {
values: number[];
}

/**
* Details object that may be included in an error response.
* @public
*/
export interface ErrorDetails {
"@type"?: string;
reason?: string;
domain?: string;
metadata?: Record<string, unknown>;
[key: string]: unknown;
}

0 comments on commit 518ea36

Please sign in to comment.