All quizzesHard
Pipeline Internals — Series 2
Preview — 3 of 10 questions
Given this, what is true of a guard that returns false?
javascript
// simplified GuardsConsumer
const canActivate = await guard.canActivate(context);
if (!canActivate) throw new ForbiddenException();AThe request is silently dropped without a response, since no exception is constructed
BThe 403 is produced by the HTTP adapter, so exception filters cannot intercept it
CThe consumer throws a real ForbiddenException on your behalf, so the failure travels the normal exception path and a filter matching HttpException (or ForbiddenException) can reshape the response
DThe framework returns 403 directly from the guard's stack frame, bypassing the interceptor chain entirely
Which filter handles the exception?
javascript
@Catch()
export class AllExceptionsFilter implements ExceptionFilter {
catch(exception: unknown, host: ArgumentsHost) { /* ... */ }
}
@UseFilters(AllExceptionsFilter, HttpExceptionFilter)
@Get() findAll() { throw new BadRequestException(); }AAllExceptionsFilter — @Catch() with no arguments matches every exception type, and within one binding the filters are tried in declaration order, so the catch-all shadows anything listed after it
BHttpExceptionFilter, because a more specific @Catch() always wins over a catch-all
CBoth, with the more specific one running second to refine the response
DNeither; two filters on the same binding cancel each other out
What does the option change?
javascript
export const Tenant = createParamDecorator((_: unknown, ctx: ExecutionContext) =>
ctx.switchToHttp().getRequest().headers['x-tenant'],
);
@Get() findAll(@Tenant() tenant: TenantDto) {}
// global: new ValidationPipe({ validateCustomDecorators: true })AIt allows custom decorators to declare their own pipes, which is otherwise forbidden
BIt validates the decorator's data argument rather than its returned value
CIt disables validation for built-in decorators so only custom ones are checked
DValues produced by createParamDecorator carry the metadata type 'custom', which the global ValidationPipe skips by default; enabling the option makes it validate those arguments too
Sign up free to play
Answer all 10 questions (7 more), see explanations for every answer, and track your score.