-
-
Notifications
You must be signed in to change notification settings - Fork 355
/
Copy patherrors.ts
48 lines (41 loc) · 1.53 KB
/
errors.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import {
COMPILE_ERROR_CODES_EXTEND_POINT,
createCompileError
} from '@intlify/message-compiler'
import type { BaseError } from '@intlify/shared'
export interface CoreError extends BaseError {}
export const CoreErrorCodes = {
INVALID_ARGUMENT: COMPILE_ERROR_CODES_EXTEND_POINT as number, // 17
INVALID_DATE_ARGUMENT: 18,
INVALID_ISO_DATE_ARGUMENT: 19,
NOT_SUPPORT_NON_STRING_MESSAGE: 20,
NOT_SUPPORT_LOCALE_PROMISE_VALUE: 21,
NOT_SUPPORT_LOCALE_ASYNC_FUNCTION: 22,
NOT_SUPPORT_LOCALE_TYPE: 23
} as const
export const CORE_ERROR_CODES_EXTEND_POINT = 24
export type CoreErrorCodes =
(typeof CoreErrorCodes)[keyof typeof CoreErrorCodes]
export function createCoreError(code: CoreErrorCodes): CoreError {
return createCompileError(
code,
null,
__DEV__ ? { messages: errorMessages } : undefined
)
}
/** @internal */
export const errorMessages: { [code: number]: string } = {
[CoreErrorCodes.INVALID_ARGUMENT]: 'Invalid arguments',
[CoreErrorCodes.INVALID_DATE_ARGUMENT]:
'The date provided is an invalid Date object.' +
'Make sure your Date represents a valid date.',
[CoreErrorCodes.INVALID_ISO_DATE_ARGUMENT]:
'The argument provided is not a valid ISO date string',
[CoreErrorCodes.NOT_SUPPORT_NON_STRING_MESSAGE]:
'Not support non-string message',
[CoreErrorCodes.NOT_SUPPORT_LOCALE_PROMISE_VALUE]:
'cannot support promise value',
[CoreErrorCodes.NOT_SUPPORT_LOCALE_ASYNC_FUNCTION]:
'cannot support async function',
[CoreErrorCodes.NOT_SUPPORT_LOCALE_TYPE]: 'cannot support locale type'
}