Skip to content

Commit

Permalink
fix: Cast errors in a backwards-compatible way
Browse files Browse the repository at this point in the history
  • Loading branch information
WoH committed Sep 14, 2021
1 parent c6a8e2a commit c212f66
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/routeGeneration/templates/express.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function RegisterRoutes(app: express.Router) {
let validatedArgs: any[] = [];
try {
validatedArgs = getValidatedArgs(args, request, response);
} catch (err: any) {
} catch (err) {
return next(err);
}

Expand Down Expand Up @@ -156,7 +156,7 @@ export function RegisterRoutes(app: express.Router) {
request['user'] = await promiseAny(secMethodOrPromises);
next();
}
catch(err: any) {
catch(err) {
// Show most recent error as response
const error = failedAttempts.pop();
error.status = error.status || 401;
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/routeGeneration/templates/hapi.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ export function RegisterRoutes(server: any) {
let validatedArgs: any[] = [];
try {
validatedArgs = getValidatedArgs(args, request, h);
} catch (error: any) {
} catch (err) {
const error = err as any;
if (isBoom(error)) {
throw error;
}
Expand Down Expand Up @@ -186,7 +187,7 @@ export function RegisterRoutes(server: any) {
request['user'] = await promiseAny(secMethodOrPromises);
return request['user'];
}
catch(err: any) {
catch(err) {
// Show most recent error as response
const error = failedAttempts.pop();
if (isBoom(error)) {
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/routeGeneration/templates/koa.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export function RegisterRoutes(router: KoaRouter) {
let validatedArgs: any[] = [];
try {
validatedArgs = getValidatedArgs(args, context, next);
} catch (error: any) {
} catch (err) {
const error = err as any;
context.status = error.status;
context.throw(error.status, JSON.stringify({ fields: error.fields }));
}
Expand Down Expand Up @@ -155,7 +156,7 @@ export function RegisterRoutes(router: KoaRouter) {
success = true;
context.request['user'] = user;
}
catch(err: any) {
catch(err) {
// Show most recent error as response
const error = failedAttempts.pop();
context.status = error.status || 401;
Expand Down

0 comments on commit c212f66

Please sign in to comment.