Skip to content

Commit

Permalink
fix(dcellar-web-ui): semantic delegate create folder error message
Browse files Browse the repository at this point in the history
  • Loading branch information
devinxl committed Sep 6, 2024
1 parent 393b835 commit ccf0263
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 10 additions & 0 deletions apps/dcellar-web-ui/src/facade/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,13 @@ export const queryLockFeeFault = (e: any): ErrorResponse => {

return [null, E_UNKNOWN_ERROR];
};

export const semanticRPCError = (err: string): string => {
if (!err) return E_UNKNOWN_ERROR;
const errorList = [
{ key: 'is frozen', message: 'Your account is frozen. Please deposit to reactivate it.' },
];
const foundError = errorList.find(({ key }) => err.includes(key));

return foundError?.message ?? err;
};
5 changes: 3 additions & 2 deletions apps/dcellar-web-ui/src/facade/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
commonFault,
createTxFault,
queryLockFeeFault,
semanticRPCError,
simulateFault,
} from '@/facade/error';
import { getClient } from '@/facade/index';
Expand Down Expand Up @@ -720,8 +721,8 @@ export const delegateCreateFolder = async (
.delegateCreateFolder(request, auth)
.then(resolve, commonFault);

if (!result || error) return [null, error];
if (result.code !== 0 || !result.body) return [null, result.message ?? ''];
if (!result || error) return [null, semanticRPCError(error)];
if (result.code !== 0 || !result.body) return [null, semanticRPCError(result.message ?? '')];

return [result.body, null];
};

0 comments on commit ccf0263

Please sign in to comment.