refactored errorMessageParsing to error Util
This commit is contained in:
parent
ca81f764e5
commit
a9e6c8a938
2 changed files with 22 additions and 17 deletions
|
@ -1,30 +1,15 @@
|
|||
import React from 'react';
|
||||
import { Alert } from 'react-bootstrap';
|
||||
|
||||
import constants from 'utils/strings/constants';
|
||||
import {errorCodes} from 'utils/common/errorUtil';
|
||||
import { ErrorBannerMessage } from 'utils/common/errorUtil';
|
||||
|
||||
export default function AlertBanner({ bannerErrorCode }) {
|
||||
let errorMessage;
|
||||
switch (bannerErrorCode) {
|
||||
case errorCodes.ERR_NO_ACTIVE_SUBSCRIPTION:
|
||||
errorMessage = constants.SUBSCRIPTION_EXPIRED;
|
||||
break;
|
||||
case errorCodes.ERR_STORAGE_LIMIT_EXCEEDED:
|
||||
errorMessage = constants.STORAGE_QUOTA_EXCEEDED;
|
||||
break;
|
||||
case errorCodes.ERR_NO_INTERNET_CONNECTION:
|
||||
errorMessage = constants.NO_INTERNET_CONNECTION;
|
||||
break;
|
||||
default:
|
||||
errorMessage = `Unknown Error Code - ${bannerErrorCode} Encountered`;
|
||||
}
|
||||
return (
|
||||
<Alert
|
||||
variant={'danger'}
|
||||
style={{ display: bannerErrorCode ? 'block' : 'none' }}
|
||||
>
|
||||
{errorMessage}
|
||||
{ErrorBannerMessage(bannerErrorCode)}
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import constants from 'utils/strings/constants';
|
||||
|
||||
export const errorCodes = {
|
||||
ERR_STORAGE_LIMIT_EXCEEDED: '426',
|
||||
ERR_NO_ACTIVE_SUBSCRIPTION: '402',
|
||||
|
@ -16,3 +18,21 @@ export function ErrorHandler(error) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export function ErrorBannerMessage(bannerErrorCode) {
|
||||
let errorMessage;
|
||||
switch (bannerErrorCode) {
|
||||
case errorCodes.ERR_NO_ACTIVE_SUBSCRIPTION:
|
||||
errorMessage = constants.SUBSCRIPTION_EXPIRED;
|
||||
break;
|
||||
case errorCodes.ERR_STORAGE_LIMIT_EXCEEDED:
|
||||
errorMessage = constants.STORAGE_QUOTA_EXCEEDED;
|
||||
break;
|
||||
case errorCodes.ERR_NO_INTERNET_CONNECTION:
|
||||
errorMessage = constants.NO_INTERNET_CONNECTION;
|
||||
break;
|
||||
default:
|
||||
errorMessage = `Unknown Error Code - ${bannerErrorCode} Encountered`;
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue