mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 16:24:25 +08:00
show friendly error when user registration is disabled
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import { defaultLanguage, allLanguages } from '../locales/index.js'
|
||||
|
||||
const apiNotFoundErrorCode = 100001;
|
||||
const specifiedApiNotFoundErrors = {
|
||||
'/api/register.json': {
|
||||
message: 'User registration is disabled'
|
||||
}
|
||||
};
|
||||
const validatorErrorCode = 200000;
|
||||
const parameterizedErrors = [
|
||||
{
|
||||
@@ -134,6 +140,12 @@ export function getI18nOptions() {
|
||||
}
|
||||
|
||||
export function getLocalizedError(error) {
|
||||
if (error.errorCode === apiNotFoundErrorCode && specifiedApiNotFoundErrors[error.path]) {
|
||||
return {
|
||||
message: `${specifiedApiNotFoundErrors[error.path].message}`
|
||||
};
|
||||
}
|
||||
|
||||
if (error.errorCode !== validatorErrorCode) {
|
||||
return {
|
||||
message: `error.${error.errorMessage}`
|
||||
|
||||
Reference in New Issue
Block a user