import { BadRequestException, HttpStatus } from '@nestjs/common';

/**
 * RFC 6749 §5.2 — `unauthorized_client`: the authenticated client is not authorized to use
 * this authorization grant type. Distinct from `invalid_client` (which is an authentication
 * failure): here the client authenticated correctly but has no `OAuthClient` configured for
 * the requested grant. Returned with HTTP 400.
 *
 * `statusCode` is included in the body so the NestJS Apollo driver's
 * `createTransformHttpErrorFn` sets `extensions.originalError`.
 */
export class UnauthorizedClientError extends BadRequestException {
  constructor() {
    super({ statusCode: HttpStatus.BAD_REQUEST, error: 'unauthorized_client' });
  }
}
