Skip to content

Commit

Permalink
fix(core): Surface enterprise trial error message (#10267)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov authored Aug 2, 2024
1 parent 42ba884 commit 432ac1d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/cli/src/license/license.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Get, Post, RestController, GlobalScope } from '@/decorators';
import { AuthenticatedRequest, LicenseRequest } from '@/requests';
import { LicenseService } from './license.service';
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
import type { AxiosError } from 'axios';

@RestController('/license')
export class LicenseController {
Expand All @@ -14,7 +16,18 @@ export class LicenseController {
@Post('/enterprise/request_trial')
@GlobalScope('license:manage')
async requestEnterpriseTrial(req: AuthenticatedRequest) {
await this.licenseService.requestEnterpriseTrial(req.user);
try {
await this.licenseService.requestEnterpriseTrial(req.user);
} catch (error: unknown) {
if (error instanceof Error) {
const errorMsg =
(error as AxiosError<{ message: string }>).response?.data?.message ?? error.message;

throw new BadRequestError(errorMsg);
} else {
throw new BadRequestError('Failed to request trial');
}
}
}

@Post('/activate')
Expand Down

0 comments on commit 432ac1d

Please sign in to comment.