Update user friendly errors for translations (#15000)
Force msg typing instead of string for user friendly errors
This commit is contained in:
+9
-6
@@ -1,6 +1,7 @@
|
||||
/* @license Enterprise */
|
||||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import Cloudflare from 'cloudflare';
|
||||
import {
|
||||
type CustomHostnameCreateParams,
|
||||
@@ -8,14 +9,14 @@ import {
|
||||
} from 'cloudflare/resources/custom-hostnames/custom-hostnames';
|
||||
import { assertIsDefinedOrThrow, isDefined } from 'twenty-shared/utils';
|
||||
|
||||
import { type DomainValidRecords } from 'src/engine/core-modules/dns-manager/dtos/domain-valid-records';
|
||||
import {
|
||||
DnsManagerException,
|
||||
DnsManagerExceptionCode,
|
||||
} from 'src/engine/core-modules/dns-manager/exceptions/dns-manager.exception';
|
||||
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service';
|
||||
import { dnsManagerValidator } from 'src/engine/core-modules/dns-manager/validator/dns-manager.validate';
|
||||
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { type DomainValidRecords } from 'src/engine/core-modules/dns-manager/dtos/domain-valid-records';
|
||||
|
||||
type DnsManagerOptions = {
|
||||
isPublicDomain?: boolean;
|
||||
@@ -43,7 +44,7 @@ export class DnsManagerService {
|
||||
throw new DnsManagerException(
|
||||
'Hostname already registered',
|
||||
DnsManagerExceptionCode.HOSTNAME_ALREADY_REGISTERED,
|
||||
{ userFriendlyMessage: 'Domain is already registered' },
|
||||
{ userFriendlyMessage: msg`Domain is already registered` },
|
||||
);
|
||||
}
|
||||
|
||||
@@ -66,8 +67,7 @@ export class DnsManagerService {
|
||||
'Missing public domain URL',
|
||||
DnsManagerExceptionCode.MISSING_PUBLIC_DOMAIN_URL,
|
||||
{
|
||||
userFriendlyMessage:
|
||||
'Public domain URL is not defined. Please set the PUBLIC_DOMAIN_URL environment variable',
|
||||
userFriendlyMessage: msg`Public domain URL is not defined. Please set the PUBLIC_DOMAIN_URL environment variable`,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -219,11 +219,14 @@ export class DnsManagerService {
|
||||
}
|
||||
|
||||
// should never happen. error 5xx
|
||||
const hostnameCount = customHostnames.result.length;
|
||||
const domainName = hostname;
|
||||
|
||||
throw new DnsManagerException(
|
||||
'More than one custom hostname found in cloudflare',
|
||||
DnsManagerExceptionCode.MULTIPLE_HOSTNAMES_FOUND,
|
||||
{
|
||||
userFriendlyMessage: `${customHostnames.result.length} hostnames found for domain '${hostname}'. Expect 1`,
|
||||
userFriendlyMessage: msg`${hostnameCount} hostnames found for domain '${domainName}'. Expect 1`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
|
||||
import type Cloudflare from 'cloudflare';
|
||||
|
||||
@@ -15,7 +15,7 @@ const isCloudflareInstanceDefined = (
|
||||
'Cloudflare instance is not defined',
|
||||
DnsManagerExceptionCode.CLOUDFLARE_CLIENT_NOT_INITIALIZED,
|
||||
{
|
||||
userFriendlyMessage: t`Environment variable CLOUDFLARE_API_KEY must be defined to use this feature.`,
|
||||
userFriendlyMessage: msg`Environment variable CLOUDFLARE_API_KEY must be defined to use this feature.`,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user