From 905d2895cc48866120fb49670020feb2ab09ceb1 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 10 Sep 2024 13:12:09 +0200 Subject: [PATCH 1/2] Remove ApiError::getMessage, ApiError::getField, and ApiError::getStatusCode. The values returned by these functions are available as (public) properties. --- src/errors/ApiError.ts | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/src/errors/ApiError.ts b/src/errors/ApiError.ts index a6bc595b..9710a12a 100644 --- a/src/errors/ApiError.ts +++ b/src/errors/ApiError.ts @@ -27,36 +27,6 @@ export default class ApiError extends Error { Object.defineProperty(this, 'message', { enumerable: true }); } - /** - * Get the error message - * - * @since 3.0.0 - * @deprecated Use `error.message` instead. - */ - public getMessage(): string { - return this.message; - } - - /** - * Get the field name that contains an error - * - * @since 3.0.0 - * @deprecated Use `error.field` instead. - */ - public getField(): Maybe { - return this.field; - } - - /** - * Get the API status code - * - * @since 3.0.0 - * @deprecated Use `error.statusCode` instead. - */ - public getStatusCode(): Maybe { - return this.statusCode; - } - /** * Get the documentation URL * From 734f57fc09b79e3fff664f9cdb7131353c48e708 Mon Sep 17 00:00:00 2001 From: "Pimm \"de Chinchilla\" Hogeling" Date: Tue, 10 Sep 2024 15:56:44 +0200 Subject: [PATCH 2/2] Fix test. --- tests/unit/resources/methods.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/resources/methods.test.ts b/tests/unit/resources/methods.test.ts index 3d9ac7fa..dff843a5 100644 --- a/tests/unit/resources/methods.test.ts +++ b/tests/unit/resources/methods.test.ts @@ -46,7 +46,7 @@ describe('methods', () => { }) .catch(err => { expect(err).toBeInstanceOf(ApiError); - expect(err.getMessage()).toEqual(error.detail); + expect(err.message).toEqual(error.detail); }); }); }); @@ -57,7 +57,7 @@ describe('methods', () => { return new Promise(resolve => { methods.get('foo', {}, (err: any, result) => { expect(err).toBeInstanceOf(ApiError); - expect(err.getMessage()).toEqual(error.detail); + expect(err.message).toEqual(error.detail); expect(result).toBeUndefined(); resolve(); });