Skip to content

Commit

Permalink
when the error returned from interactive example server is not array …
Browse files Browse the repository at this point in the history
…of pairs, that means it is a validation error even before checking the examples. So we need to show such error messages in a toast and bail out to avoid the infinite spinner
  • Loading branch information
nashjain committed Dec 16, 2024
1 parent 4ed708c commit b10030b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ data class ExampleValidationErrorMessage(val fullErrorMessageString: String) {
}

private fun extractDescriptions(reportString: String): List<String> {
val parts = reportString.split("$BREADCRUMB_PREFIX")
val parts = reportString.split(BREADCRUMB_PREFIX)

return parts.drop(1)
.map { "$BREADCRUMB_PREFIX$it".trim() }
Expand Down
8 changes: 5 additions & 3 deletions core/src/main/resources/templates/examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1743,12 +1743,14 @@ <h2 th:text="${contractFilePath}"></h2>
gutters: ["CodeMirror-lint-markers"]
});


if (example.error) {
highlightErrorLines(editor, example.error, example.exampleJson);
if (typeof example.error === 'object' && !Array.isArray(example.error)) {
highlightErrorLines(editor, example.error, example.exampleJson);
} else {
createAlert("Example Validation Failed", example.error, true);
}
}


editor.on("change", (instance, changes) => {
isSaved = false;
updateBorderColorExampleBlock(editor, examplePreDiv);
Expand Down

0 comments on commit b10030b

Please sign in to comment.