mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-11 12:57:29 -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 { Get, Post, RestController, GlobalScope } from '@/decorators';
|
||||||
import { AuthenticatedRequest, LicenseRequest } from '@/requests';
|
import { AuthenticatedRequest, LicenseRequest } from '@/requests';
|
||||||
import { LicenseService } from './license.service';
|
import { LicenseService } from './license.service';
|
||||||
|
import { BadRequestError } from '@/errors/response-errors/bad-request.error';
|
||||||
|
import type { AxiosError } from 'axios';
|
||||||
|
|
||||||
@RestController('/license')
|
@RestController('/license')
|
||||||
export class LicenseController {
|
export class LicenseController {
|
||||||
|
@ -14,7 +16,18 @@ export class LicenseController {
|
||||||
@Post('/enterprise/request_trial')
|
@Post('/enterprise/request_trial')
|
||||||
@GlobalScope('license:manage')
|
@GlobalScope('license:manage')
|
||||||
async requestEnterpriseTrial(req: AuthenticatedRequest) {
|
async requestEnterpriseTrial(req: AuthenticatedRequest) {
|
||||||
|
try {
|
||||||
await this.licenseService.requestEnterpriseTrial(req.user);
|
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')
|
@Post('/activate')
|
||||||
|
|
Loading…
Reference in a new issue