Skip to content

Commit 3b4301a

Browse files
committed
Rename httpErrorData to customErrorData to make more future-proof
1 parent c01003c commit 3b4301a

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

packages/vertexai/src/errors.ts

+3-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
import { FirebaseError } from '@firebase/util';
1919
import {
2020
VertexAIErrorCode,
21-
GenerateContentResponse,
22-
HTTPErrorDetails
21+
CustomErrorData
2322
} from './types';
2423
import { VERTEX_TYPE } from './constants';
2524

@@ -34,14 +33,12 @@ export class VertexAIError extends FirebaseError {
3433
*
3534
* @param code - The error code from {@link VertexAIErrorCode}.
3635
* @param message - A human-readable message describing the error.
37-
* @param HTTPErrorDetails - Optional HTTP details from a bad response.
38-
* @param generateContentResponse - Optional response from a {@link GenerateContentRequest}.
36+
* @param customErrorData - Optional error data.
3937
*/
4038
constructor(
4139
readonly code: VertexAIErrorCode,
4240
readonly message: string,
43-
readonly httpErrorDetails?: HTTPErrorDetails,
44-
readonly generateContentResponse?: GenerateContentResponse
41+
readonly customErrorData?: CustomErrorData,
4542
) {
4643
// Match error format used by FirebaseError from ErrorFactory
4744
const service = VERTEX_TYPE;

packages/vertexai/src/requests/request.test.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ describe('request methods', () => {
249249
expect((e as VertexAIError).code).to.equal(
250250
VertexAIErrorCode.FETCH_ERROR
251251
);
252-
expect((e as VertexAIError).httpErrorDetails?.status).to.equal(500);
253-
expect((e as VertexAIError).httpErrorDetails?.statusText).to.equal(
252+
expect((e as VertexAIError).customErrorData?.status).to.equal(500);
253+
expect((e as VertexAIError).customErrorData?.statusText).to.equal(
254254
'AbortError'
255255
);
256256
expect((e as VertexAIError).message).to.include('500 AbortError');
@@ -276,8 +276,8 @@ describe('request methods', () => {
276276
expect((e as VertexAIError).code).to.equal(
277277
VertexAIErrorCode.FETCH_ERROR
278278
);
279-
expect((e as VertexAIError).httpErrorDetails?.status).to.equal(500);
280-
expect((e as VertexAIError).httpErrorDetails?.statusText).to.equal(
279+
expect((e as VertexAIError).customErrorData?.status).to.equal(500);
280+
expect((e as VertexAIError).customErrorData?.statusText).to.equal(
281281
'Server Error'
282282
);
283283
expect((e as VertexAIError).message).to.include('500 Server Error');
@@ -303,8 +303,8 @@ describe('request methods', () => {
303303
expect((e as VertexAIError).code).to.equal(
304304
VertexAIErrorCode.FETCH_ERROR
305305
);
306-
expect((e as VertexAIError).httpErrorDetails?.status).to.equal(500);
307-
expect((e as VertexAIError).httpErrorDetails?.statusText).to.equal(
306+
expect((e as VertexAIError).customErrorData?.status).to.equal(500);
307+
expect((e as VertexAIError).customErrorData?.statusText).to.equal(
308308
'Server Error'
309309
);
310310
expect((e as VertexAIError).message).to.include('500 Server Error');
@@ -343,8 +343,8 @@ describe('request methods', () => {
343343
expect((e as VertexAIError).code).to.equal(
344344
VertexAIErrorCode.FETCH_ERROR
345345
);
346-
expect((e as VertexAIError).httpErrorDetails?.status).to.equal(500);
347-
expect((e as VertexAIError).httpErrorDetails?.statusText).to.equal(
346+
expect((e as VertexAIError).customErrorData?.status).to.equal(500);
347+
expect((e as VertexAIError).customErrorData?.statusText).to.equal(
348348
'Server Error'
349349
);
350350
expect((e as VertexAIError).message).to.include('500 Server Error');

packages/vertexai/src/types/error.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { GenerateContentResponse } from './responses';
19+
1820
/**
1921
* Details object that may be included in an error response.
2022
*
@@ -41,12 +43,15 @@ export interface ErrorDetails {
4143
*
4244
* @public
4345
*/
44-
export interface HTTPErrorDetails {
46+
export interface CustomErrorData {
4547
/** HTTP status code of the error response. */
46-
status: number;
48+
status?: number;
4749

4850
/** HTTP status text of the error response. */
49-
statusText: string;
51+
statusText?: string;
52+
53+
/** Response from a {@link GenerateContentRequest} */
54+
generateContentResponse?: GenerateContentResponse;
5055

5156
/** Optional additional details about the error. */
5257
errorDetails?: ErrorDetails[];

0 commit comments

Comments
 (0)