mirror of
https://github.com/simstudioai/sim.git
synced 2026-04-28 03:00:29 -04:00
fix(tools): handle all Atlassian error formats in parseJsmErrorMessage
The route-level error parser only checked for errorMessage (JSM format), missing errorMessages array (Jira), errors[].title (Forms/Confluence RFC 7807), and message (gateway). Now mirrors the same logic as the atlassian-errors extractor for consistent error extraction at both layers.
This commit is contained in:
@@ -50,13 +50,29 @@ export function parseJsmErrorMessage(
|
||||
): string {
|
||||
try {
|
||||
const errorData = JSON.parse(errorText)
|
||||
// JSM Service Desk: singular errorMessage
|
||||
if (errorData.errorMessage) {
|
||||
return `JSM Forms API error: ${errorData.errorMessage}`
|
||||
return errorData.errorMessage
|
||||
}
|
||||
// Jira Platform: errorMessages array
|
||||
if (Array.isArray(errorData.errorMessages) && errorData.errorMessages.length > 0) {
|
||||
return errorData.errorMessages.join(', ')
|
||||
}
|
||||
// Confluence v2 / Forms API: RFC 7807 errors array
|
||||
if (Array.isArray(errorData.errors) && errorData.errors.length > 0) {
|
||||
const err = errorData.errors[0]
|
||||
if (err?.title) {
|
||||
return err.detail ? `${err.title}: ${err.detail}` : err.title
|
||||
}
|
||||
}
|
||||
// Generic message fallback
|
||||
if (errorData.message) {
|
||||
return errorData.message
|
||||
}
|
||||
} catch {
|
||||
if (errorText) {
|
||||
return `JSM Forms API error: ${errorText}`
|
||||
return errorText
|
||||
}
|
||||
}
|
||||
return `JSM Forms API error: ${status} ${statusText}`
|
||||
return `${status} ${statusText}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user