Skip to content

Commit bdea28f

Browse files
feat: expand some typings
1 parent bd8ff73 commit bdea28f

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/auth/interceptors/createProcessAxiosRequestErrorInterceptor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-check
12
import { processAxiosError } from '../utils.js';
23

34
const createProcessAxiosRequestErrorInterceptor = (options) => {

src/auth/interface.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,21 @@ export async function hydrateAuthenticatedUser() {
256256
* @typedef {import("axios").Axios} HttpClient
257257
*/
258258

259+
/**
260+
* @typedef {Object} CustomErrorAttributes
261+
* @property {number} [httpErrorStatus]
262+
* @property {'unknown-api-request-error'|'api-response-error'|'api-request-error'|'api-request-config-error'
263+
* } [httpErrorType]
264+
* @property {string} [httpErrorMessage]
265+
* @property {string} [httpErrorRequestUrl]
266+
* @property {string} [httpErrorRequestMethod]
267+
* @property {any} [httpErrorResponseData]
268+
*/
269+
270+
/**
271+
* @typedef {import("axios").AxiosError & {customAttributes: CustomErrorAttributes}} DetailedAxiosError
272+
*/
273+
259274
/**
260275
* @typedef {Object} AuthService
261276
* @property {typeof getAuthenticatedHttpClient} getAuthenticatedHttpClient

src/auth/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ const logFrontendAuthError = (loggingService, error) => {
3636
loggingService.logError(prefixedMessageError, prefixedMessageError.customAttributes);
3737
};
3838

39+
/**
40+
* Handle an Axios error
41+
* @param {import("axios").AxiosError} axiosErrorObject The error
42+
* @returns {import("./interface").DetailedAxiosError}
43+
*/
3944
const processAxiosError = (axiosErrorObject) => {
45+
/** @type {import("./interface").DetailedAxiosError} */
4046
const error = Object.create(axiosErrorObject);
4147
const { request, response, config } = error;
4248

0 commit comments

Comments
 (0)