Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/core-base/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export interface CoreError extends CompileError {
code: CoreErrorCodes
}

let code = CompileErrorCodes.__EXTEND_POINT__
const inc = () => code++

export const CoreErrorCodes = {
INVALID_ARGUMENT: CompileErrorCodes.__EXTEND_POINT__,
INVALID_DATE_ARGUMENT: CompileErrorCodes.__EXTEND_POINT__ + 1,
INVALID_ISO_DATE_ARGUMENT: CompileErrorCodes.__EXTEND_POINT__ + 2,
__EXTEND_POINT__: CompileErrorCodes.__EXTEND_POINT__ + 3
INVALID_ARGUMENT: code, // 15
INVALID_DATE_ARGUMENT: inc(), // 16
INVALID_ISO_DATE_ARGUMENT: inc(), // 17
__EXTEND_POINT__: inc() // 18
} as const

export type CoreErrorCodes = typeof CoreErrorCodes[keyof typeof CoreErrorCodes]
Expand Down
23 changes: 13 additions & 10 deletions packages/vue-i18n/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ export interface I18nError extends CompileError {
code: I18nErrorCodes
}

let code = CompileErrorCodes.__EXTEND_POINT__
const inc = () => code++

export const I18nErrorCodes = {
// composer module errors
UNEXPECTED_RETURN_TYPE: CompileErrorCodes.__EXTEND_POINT__,
UNEXPECTED_RETURN_TYPE: code, // 15
// legacy module errors
INVALID_ARGUMENT: CompileErrorCodes.__EXTEND_POINT__ + 1,
INVALID_ARGUMENT: inc(), // 16
// i18n module errors
MUST_BE_CALL_SETUP_TOP: CompileErrorCodes.__EXTEND_POINT__ + 2,
NOT_INSLALLED: CompileErrorCodes.__EXTEND_POINT__ + 3,
NOT_AVAILABLE_IN_LEGACY_MODE: CompileErrorCodes.__EXTEND_POINT__ + 4,
MUST_BE_CALL_SETUP_TOP: inc(), // 17
NOT_INSLALLED: inc(), // 18
NOT_AVAILABLE_IN_LEGACY_MODE: inc(), // 19
// directive module errors
REQUIRED_VALUE: CompileErrorCodes.__EXTEND_POINT__ + 5,
INVALID_VALUE: CompileErrorCodes.__EXTEND_POINT__ + 6,
REQUIRED_VALUE: inc(), // 20
INVALID_VALUE: inc(), // 21
// vue-devtools errors
CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: CompileErrorCodes.__EXTEND_POINT__ + 7,
CANNOT_SETUP_VUE_DEVTOOLS_PLUGIN: inc(), // 22
// unexpected error
UNEXPECTED_ERROR: CompileErrorCodes.__EXTEND_POINT__ + 8,
UNEXPECTED_ERROR: inc(), // 23
// for enhancement
__EXTEND_POINT__: CompileErrorCodes.__EXTEND_POINT__ + 9
__EXTEND_POINT__: inc() // 24
} as const

type I18nErrorCodes = typeof I18nErrorCodes[keyof typeof I18nErrorCodes]
Expand Down
17 changes: 10 additions & 7 deletions packages/vue-i18n/src/warnings.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { format } from '@intlify/shared'
import { CoreWarnCodes } from '@intlify/core-base'

let code = CoreWarnCodes.__EXTEND_POINT__
const inc = () => code++

export const I18nWarnCodes = {
FALLBACK_TO_ROOT: CoreWarnCodes.__EXTEND_POINT__,
NOT_SUPPORTED_PRESERVE: CoreWarnCodes.__EXTEND_POINT__ + 1,
NOT_SUPPORTED_FORMATTER: CoreWarnCodes.__EXTEND_POINT__ + 2,
NOT_SUPPORTED_PRESERVE_DIRECTIVE: CoreWarnCodes.__EXTEND_POINT__ + 3,
NOT_SUPPORTED_GET_CHOICE_INDEX: CoreWarnCodes.__EXTEND_POINT__ + 4,
COMPONENT_NAME_LEGACY_COMPATIBLE: CoreWarnCodes.__EXTEND_POINT__ + 5,
NOT_FOUND_PARENT_SCOPE: CoreWarnCodes.__EXTEND_POINT__ + 6
FALLBACK_TO_ROOT: code, // 7
NOT_SUPPORTED_PRESERVE: inc(), // 8
NOT_SUPPORTED_FORMATTER: inc(), // 9
NOT_SUPPORTED_PRESERVE_DIRECTIVE: inc(), // 10
NOT_SUPPORTED_GET_CHOICE_INDEX: inc(), // 11
COMPONENT_NAME_LEGACY_COMPATIBLE: inc(), // 12
NOT_FOUND_PARENT_SCOPE: inc() // 13
} as const

type I18nWarnCodes = typeof I18nWarnCodes[keyof typeof I18nWarnCodes]
Expand Down