Skip to content

Commit 0fb0ea7

Browse files
authored
chore: show original jwt error (#7161)
1 parent 4c91df7 commit 0fb0ea7

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/cubejs-api-gateway/src/CubejsHandlerError.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ export class CubejsHandlerError extends Error {
22
public constructor(
33
public readonly status: number,
44
public readonly type: string,
5-
message: string
5+
message: string,
6+
public readonly originalError?: Error
67
) {
78
super(message || type);
89
}

packages/cubejs-api-gateway/src/gateway.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,9 +2145,9 @@ class ApiGateway {
21452145
try {
21462146
req.securityContext = await checkAuthFn(auth, secret);
21472147
req.signedWithPlaygroundAuthSecret = Boolean(internalOptions?.isPlaygroundCheckAuth);
2148-
} catch (e) {
2148+
} catch (e: any) {
21492149
if (this.enforceSecurityChecks) {
2150-
throw new CubejsHandlerError(403, 'Forbidden', 'Invalid token');
2150+
throw new CubejsHandlerError(403, 'Forbidden', 'Invalid token', e);
21512151
}
21522152
}
21532153
} else if (this.enforceSecurityChecks) {
@@ -2267,11 +2267,12 @@ class ApiGateway {
22672267
}
22682268
} catch (e: unknown) {
22692269
if (e instanceof CubejsHandlerError) {
2270+
const error = e.originalError || e;
22702271
this.log({
2271-
type: (e as Error).message,
2272+
type: error.message,
22722273
url: req.url,
22732274
token,
2274-
error: (e as Error).stack || (e as Error).toString()
2275+
error: error.stack || error.toString()
22752276
}, <any>req);
22762277

22772278
res.status(e.status).json({ error: e.message });

0 commit comments

Comments
 (0)