chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Parse plugin error message from nested error structure
|
||||
* Extracts the real error message from PluginInvokeError JSON string
|
||||
*
|
||||
* @example
|
||||
* Input: { message: "req_id: xxx PluginInvokeError: {\"message\":\"Bad credentials\"}" }
|
||||
* Output: "Bad credentials"
|
||||
*
|
||||
* @param error - Error object (an Error or object with a message property)
|
||||
* @returns Parsed error message
|
||||
*/
|
||||
export const parsePluginErrorMessage = (error: any): string => {
|
||||
const rawMessage = error?.message || error?.toString() || 'Unknown error'
|
||||
|
||||
// Try to extract nested JSON from PluginInvokeError
|
||||
// Use greedy match .+ to capture the complete JSON object with nested braces
|
||||
const pluginErrorPattern = /PluginInvokeError:\s*(\{.+\})/
|
||||
const match = pluginErrorPattern.exec(rawMessage)
|
||||
|
||||
if (match) {
|
||||
try {
|
||||
const errorData = JSON.parse(match[1]!)
|
||||
// Return the inner message if exists
|
||||
if (errorData.message) return errorData.message
|
||||
// Fallback to error_type if message not available
|
||||
if (errorData.error_type) return errorData.error_type
|
||||
} catch (parseError) {
|
||||
console.warn('Failed to parse plugin error JSON:', parseError)
|
||||
}
|
||||
}
|
||||
|
||||
return rawMessage
|
||||
}
|
||||
Reference in new issue
Block a user