mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(core): Surface enterprise trial error message (#10267)
This commit is contained in:
parent
42ba8841c4
commit
432ac1da59
|
@ -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 {
|
||||
|
@ -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')
|
||||
|
|
Loading…
Reference in a new issue