mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-14 23:22:22 +00:00

* fix: ai response test * fix: skip edge check * fix: app list * fix: toolset conflict interactive node * fix: username show
36 lines
858 B
TypeScript
36 lines
858 B
TypeScript
import { replaceSensitiveText } from '../string/tools';
|
|
import { ERROR_RESPONSE } from './errorCode';
|
|
|
|
export const getErrText = (err: any, def = ''): any => {
|
|
const msg: string =
|
|
typeof err === 'string'
|
|
? err
|
|
: err?.response?.data?.message ||
|
|
err?.response?.message ||
|
|
err?.message ||
|
|
err?.response?.data?.msg ||
|
|
err?.response?.msg ||
|
|
err?.msg ||
|
|
err?.error ||
|
|
def;
|
|
|
|
if (ERROR_RESPONSE[msg]) {
|
|
return ERROR_RESPONSE[msg].message;
|
|
}
|
|
|
|
// Axios special
|
|
if (err?.errors && Array.isArray(err.errors) && err.errors.length > 0) {
|
|
return err.errors[0].message;
|
|
}
|
|
|
|
// msg && console.log('error =>', msg);
|
|
return replaceSensitiveText(msg);
|
|
};
|
|
|
|
export class UserError extends Error {
|
|
constructor(message: string) {
|
|
super(message);
|
|
this.name = 'UserError';
|
|
}
|
|
}
|