-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: surface actual API errors instead of generic 'No valid XML' message #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -945,6 +945,15 @@ IMPORTANT: | |||||
| // Extract wiki structure from response | ||||||
| const xmlMatch = responseText.match(/<wiki_structure>[\s\S]*?<\/wiki_structure>/m); | ||||||
| if (!xmlMatch) { | ||||||
| // Surface the actual API error instead of a generic message | ||||||
| const apiErrorMatch = responseText.match(/Error with [\w][\w ]*API:\s*[^\n]+/); | ||||||
| if (apiErrorMatch) { | ||||||
| throw new Error(apiErrorMatch[0].trim()); | ||||||
| } | ||||||
| const generalErrorMatch = responseText.match(/\nError:\s*[^\n]+/); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regex for
Suggested change
|
||||||
| if (generalErrorMatch) { | ||||||
| throw new Error(generalErrorMatch[0].trim()); | ||||||
| } | ||||||
| throw new Error('No valid XML found in response'); | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The regex for
apiErrorMatchmight fail if the provider name contains hyphens (e.g., "Google-Cloud"). Additionally, for consistency with the general error check and to ensure the error is captured even if it's at the very beginning of the response, consider using(?:^|\n)as a prefix.