File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -174,9 +174,26 @@ const submit = async (form: FormInstance, fn: () => void) => {
174174}
175175const highlightCode = (json ) => {
176176 if (json .error ) {
177+ // Parse double-encoded JSON error messages to display them cleanly
178+ let errorObj = json .error
179+
180+ // Check if the error message is a JSON string that needs parsing
181+ if (errorObj .message && typeof errorObj .message === ' string' ) {
182+ try {
183+ const parsedMessage = JSON .parse (errorObj .message )
184+ // If successful, replace the string with the parsed object
185+ errorObj = {
186+ ... errorObj ,
187+ ... parsedMessage
188+ }
189+ } catch (e ) {
190+ // If parsing fails, keep the original error object
191+ }
192+ }
193+
177194 // Display the full OBP error object with proper formatting
178195 successResponseBody .value = hljs .lineNumbersValue (
179- hljs .highlightAuto (JSON .stringify (json . error , null , 4 ), [' JSON' ]).value
196+ hljs .highlightAuto (JSON .stringify (errorObj , null , 4 ), [' JSON' ]).value
180197 )
181198 } else if (json ) {
182199 successResponseBody .value = hljs .lineNumbersValue (
You can’t perform that action at this time.
0 commit comments