CnErrorFeedback
何时使用
错误信息反馈提示/解决方案引导说明
API
export interface IErrorConstructInfo {
errorBaseInfo?: {
appName?: string;
codeKey?: string;
codeDesc?: string;
};
errorContentInfo?: {
typeCode?: 'permissionError' | 'operationError' | 'bizError' | 'sysError';
displayMode?: 'dialog' | 'tips';
errorTitle?: string;
errorLevel?: 'error' | 'warning';
confirmTexts?: string;
confirmUrl?: string;
};
errorSolution?: {
enableSolution?: boolean;
solutionType?: 'hyperlink' | 'iframe' | 'text';
text?: string;
textReason?: string;
textSolution?: string;
manualUrl?: string;
};
errorMsg?: string;
errorCode?: string | number;
}
export interface ICnErrorFeedback {
show: (errorConstructInfo: IErrorConstructInfo) => void;
}
CnRequest 接入示例
import CnErrorFeedback from '@alife/cn-error-feedback';
const findConstruct = (item) => (!item || 'success' in item ? item : findConstruct(item.data));
(response) => {
try {
const data = findConstruct(response);
const { success, errorMsg, cndbErrorMsg, errorConstructInfo = {}, errorCode } = data;
const { errorContentInfo } = errorConstructInfo || {};
if (!success) {
if (errorContentInfo) {
CnErrorFeedback.show({
...errorConstructInfo,
errorMsg: cndbErrorMsg || errorMsg,
errorCode,
});
return Promise.reject(data);
}
}
} catch (error) {}
};
参考文档