Skip to content

Commit 30c99b9

Browse files
authored
fix: default error handler type (#7355)
1 parent 54d0187 commit 30c99b9

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

.changeset/modern-comics-impress.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vue-storefront/middleware": patch
3+
---
4+
5+
**[FIXED]** type of `defaultErrorHandler`

packages/middleware/src/errors/defaultErrorHandler.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import { getAgnosticStatusCode } from "../helpers";
2-
import type { Integration } from "../types";
2+
import type { ErrorHandler } from "../types";
33

44
/**
55
* Default error handler for the middleware
66
*/
7-
export const defaultErrorHandler: Integration["errorHandler"] = (
8-
error,
9-
_req,
10-
res
11-
) => {
7+
export const defaultErrorHandler: ErrorHandler = (error, _req, res) => {
128
const status = getAgnosticStatusCode(error);
139
res.status(status);
1410
if (status < 500) {

packages/middleware/src/types/common.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ export interface ApiClientExtension<API = any, CONTEXT = any, CONFIG = any> {
111111
) => ApiClientExtensionHooks;
112112
}
113113

114+
export type ErrorHandler = (
115+
error: unknown,
116+
req: AlokaiRequest,
117+
res: AlokaiResponse
118+
) => void;
119+
114120
export interface Integration<
115121
CONFIG extends TObject = any,
116122
API extends ApiMethods = any,
@@ -162,11 +168,7 @@ export interface Integration<
162168
* };
163169
* ```
164170
*/
165-
errorHandler?: (
166-
error: unknown,
167-
req: AlokaiRequest,
168-
res: AlokaiResponse
169-
) => void;
171+
errorHandler?: ErrorHandler;
170172
}
171173

172174
export interface RequestParams {

0 commit comments

Comments
 (0)