protected _getSchema()

in src/modules/form-submissions/form-submissions.controller.ts [61:93]


  protected _getSchema(accessToken: string, formKey: string): Promise<FormSchema> {
    if (!accessToken) {
      throw new UnauthorizedException(); // TODO: i18n
    }

    return this._provider.getForm(accessToken, formKey).catch((err) => {
      if (err instanceof InvalidTokenError) {
        this._logging.logger.error(`Wrong access token!`, {
          responseCode: 401,
        });
        throw new UnauthorizedException({
          traceId: this._logging.traceId,
          message: 'Wrong access token!', // TODO: i18n
        });
      }
      if (err instanceof FormNotFoundError) {
        this._logging.logger.error(`Schema [${formKey}] is not found!`, {
          responseCode: 404,
        });
        throw new NotFoundException({
          traceId: this._logging.traceId,
          message: 'Form is not found!', // TODO: i18n
        });
      }
      this._logging.logger.error(err?.message ?? 'Unknown error', {
        responseCode: 500,
      });
      throw new InternalServerErrorException({
        traceId: this._logging.traceId,
        message: 'Unknown error while getting the form', // TODO: i18n
      });
    });
  }