Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions packages/cubejs-api-gateway/src/gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ class ApiGateway {
const jsonQuery = getJsonQueryFromGraphQLQuery(query, metaConfig, variables);
res.json({ jsonQuery });
} catch (e: any) {
const stack = getEnv('devMode') ? e.stack : undefined;
this.logger('GraphQL to JSON error', {
error: (e.stack || e).toString(),
error: (stack || e).toString(),
});
res.json({ jsonQuery: null });
}
Expand Down Expand Up @@ -2180,6 +2181,7 @@ class ApiGateway {
e, context, query, res, requestStarted
}: HandleErrorOptions) {
const requestId = getEnv('devMode') || context?.signedWithPlaygroundAuthSecret ? context?.requestId : undefined;
const stack = getEnv('devMode') ? e.stack : undefined;

const plainError = e.plainMessages;

Expand All @@ -2190,7 +2192,7 @@ class ApiGateway {
error: e.message,
duration: this.duration(requestStarted)
}, context);
res({ error: e.message, stack: e.stack, requestId, plainError }, { status: e.status });
res({ error: e.message, stack, requestId, plainError }, { status: e.status });
} else if (e.error === 'Continue wait') {
this.log({
type: 'Continue wait',
Expand Down Expand Up @@ -2219,7 +2221,7 @@ class ApiGateway {
type: e.type,
error: e.message,
plainError,
stack: e.stack,
stack,
requestId
},
{ status: 400 }
Expand All @@ -2228,10 +2230,10 @@ class ApiGateway {
this.log({
type: 'Internal Server Error',
query,
error: e.stack || e.toString(),
error: stack || e.toString(),
duration: this.duration(requestStarted)
}, context);
res({ error: e.toString(), stack: e.stack, requestId, plainError, }, { status: 500 });
res({ error: e.toString(), stack, requestId, plainError, }, { status: 500 });
}
}

Expand Down Expand Up @@ -2497,24 +2499,26 @@ class ApiGateway {
} catch (e: unknown) {
if (e instanceof CubejsHandlerError) {
const error = e.originalError || e;
const stack = getEnv('devMode') ? error.stack : undefined;
this.log({
type: error.message,
url: req.url,
token,
error: error.stack || error.toString()
error: stack || error.toString()
}, <any>req);

res.status(e.status).json({ error: e.message });
} else if (e instanceof Error) {
const stack = getEnv('devMode') ? e.stack : undefined;
this.log({
type: 'Auth Error',
token,
error: e.stack || e.toString()
error: stack || e.toString()
}, <any>req);

res.status(500).json({
error: e.toString(),
stack: e.stack
stack,
});
}
}
Expand Down Expand Up @@ -2644,10 +2648,11 @@ class ApiGateway {
};

private logProbeError(e: any, type: string): void {
const stack = getEnv('devMode') ? (e as Error).stack : undefined;
this.log({
type,
driverType: e.driverType,
error: (e as Error).stack || (e as Error).toString(),
error: stack || (e as Error).toString(),
});
}

Expand Down
Loading