change CustomError enum to Record

This commit is contained in:
Abhinav 2023-01-31 10:43:14 +05:30
parent 6969df8b39
commit 4abf00c734

View file

@ -11,44 +11,45 @@ export const ServerErrorCodes = {
NOT_FOUND: '404', NOT_FOUND: '404',
}; };
export enum CustomError { export const CustomError = {
SUBSCRIPTION_VERIFICATION_ERROR = 'Subscription verification failed', SUBSCRIPTION_VERIFICATION_ERROR: 'Subscription verification failed',
THUMBNAIL_GENERATION_FAILED = 'thumbnail generation failed', THUMBNAIL_GENERATION_FAILED: 'thumbnail generation failed',
VIDEO_PLAYBACK_FAILED = 'video playback failed', VIDEO_PLAYBACK_FAILED: 'video playback failed',
ETAG_MISSING = 'no header/etag present in response body', ETAG_MISSING: 'no header/etag present in response body',
KEY_MISSING = 'encrypted key missing from localStorage', KEY_MISSING: 'encrypted key missing from localStorage',
FAILED_TO_LOAD_WEB_WORKER = 'failed to load web worker', FAILED_TO_LOAD_WEB_WORKER: 'failed to load web worker',
CHUNK_MORE_THAN_EXPECTED = 'chunks more than expected', CHUNK_MORE_THAN_EXPECTED: 'chunks more than expected',
CHUNK_LESS_THAN_EXPECTED = 'chunks less than expected', CHUNK_LESS_THAN_EXPECTED: 'chunks less than expected',
UNSUPPORTED_FILE_FORMAT = 'unsupported file formats', UNSUPPORTED_FILE_FORMAT: 'unsupported file formats',
FILE_TOO_LARGE = 'file too large', FILE_TOO_LARGE: 'file too large',
SUBSCRIPTION_EXPIRED = 'subscription expired', SUBSCRIPTION_EXPIRED: 'subscription expired',
STORAGE_QUOTA_EXCEEDED = 'storage quota exceeded', STORAGE_QUOTA_EXCEEDED: 'storage quota exceeded',
SESSION_EXPIRED = 'session expired', SESSION_EXPIRED: 'session expired',
INVALID_MIME_TYPE = 'invalid mime type', INVALID_MIME_TYPE: (type: string) => `invalid mime type -${type}`,
SIGNUP_FAILED = 'signup failed', SIGNUP_FAILED: 'signup failed',
FAV_COLLECTION_MISSING = 'favorite collection missing', FAV_COLLECTION_MISSING: 'favorite collection missing',
INVALID_COLLECTION_OPERATION = 'invalid collection operation', INVALID_COLLECTION_OPERATION: 'invalid collection operation',
WAIT_TIME_EXCEEDED = 'thumbnail generation wait time exceeded', WAIT_TIME_EXCEEDED: 'thumbnail generation wait time exceeded',
REQUEST_CANCELLED = 'request canceled', REQUEST_CANCELLED: 'request canceled',
REQUEST_FAILED = 'request failed', REQUEST_FAILED: 'request failed',
TOKEN_EXPIRED = 'token expired', TOKEN_EXPIRED: 'token expired',
TOKEN_MISSING = 'token missing', TOKEN_MISSING: 'token missing',
TOO_MANY_REQUESTS = 'too many requests', TOO_MANY_REQUESTS: 'too many requests',
BAD_REQUEST = 'bad request', BAD_REQUEST: 'bad request',
SUBSCRIPTION_NEEDED = 'subscription not present', SUBSCRIPTION_NEEDED: 'subscription not present',
NOT_FOUND = 'not found ', NOT_FOUND: 'not found ',
NO_METADATA = 'no metadata', NO_METADATA: 'no metadata',
TOO_LARGE_LIVE_PHOTO_ASSETS = 'too large live photo assets', TOO_LARGE_LIVE_PHOTO_ASSETS: 'too large live photo assets',
NOT_A_DATE = 'not a date', NOT_A_DATE: 'not a date',
FILE_ID_NOT_FOUND = 'file with id not found', FILE_ID_NOT_FOUND: 'file with id not found',
WEAK_DEVICE = 'password decryption failed on the device', WEAK_DEVICE: 'password decryption failed on the device',
INCORRECT_PASSWORD = 'incorrect password', INCORRECT_PASSWORD: 'incorrect password',
UPLOAD_CANCELLED = 'upload cancelled', UPLOAD_CANCELLED: 'upload cancelled',
REQUEST_TIMEOUT = 'request taking too long', REQUEST_TIMEOUT: 'request taking too long',
HIDDEN_COLLECTION_SYNC_FILE_ATTEMPTED = 'hidden collection sync file attempted', HIDDEN_COLLECTION_SYNC_FILE_ATTEMPTED:
UNKNOWN_ERROR = 'Something went wrong, please try again', 'hidden collection sync file attempted',
} UNKNOWN_ERROR: 'Something went wrong, please try again',
};
function parseUploadErrorCodes(error) { function parseUploadErrorCodes(error) {
let parsedMessage = null; let parsedMessage = null;