mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-25 21:01:09 +03:00
56f9208d7c
* add export all function * modify exportAll to reuse existing code from other services * modify routes of export-import * add exportAll function into UI * add errorhandler * add importAll Function into UI for ChatFlow * modify importAll Function to import tools * remove appServer variable * modify exportAll to exportData for new requirement in backend * chore modify type camelCase to PascalCase in exportImportService * add import export for variables, assistants, and checkboxes for UI --------- Co-authored-by: Henry <hzj94@hotmail.com>
20 lines
610 B
JavaScript
20 lines
610 B
JavaScript
const isErrorWithMessage = (error) => {
|
|
return typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string'
|
|
}
|
|
|
|
const toErrorWithMessage = (maybeError) => {
|
|
if (isErrorWithMessage(maybeError)) return maybeError
|
|
|
|
try {
|
|
return new Error(JSON.stringify(maybeError))
|
|
} catch {
|
|
// fallback in case there's an error stringifying the maybeError
|
|
// like with circular references for example.
|
|
return new Error(String(maybeError))
|
|
}
|
|
}
|
|
|
|
export const getErrorMessage = (error) => {
|
|
return toErrorWithMessage(error).message
|
|
}
|