Skip to content

Commit

Permalink
Provide details on errors #15
Browse files Browse the repository at this point in the history
  • Loading branch information
hasanbalci committed Sep 8, 2022
1 parent 1eab554 commit 5fd7cdf
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 158 deletions.
6 changes: 6 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ <h3 class="ui header" style="margin-bottom: -3px; margin-right: 7.5px">Image</h3
<img class="image" id="imageContent">
</div>
</div>

<div class="ui mini modal" id="errorModal">
<div class="content">
<span id="errorContent"></span>
</div>
</div>

<div id="information-modal" class="ui small modal information" >
<i class="close icon"></i>
Expand Down
33 changes: 26 additions & 7 deletions public/js/main.menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,17 @@ let processNodes = async function () {

let data;
if (!isGraphML && !isSBGNML && !isSBML) {
data = [JSON.parse(graphData), options];
data = JSON.stringify(data);
try {
data = [JSON.parse(graphData), options];
data = JSON.stringify(data);
}
catch (e) {
let errorContent = document.getElementById("errorContent");
let errorString = "<b>Sorry! Cannot process the given file!</b><br><br>There is something wrong with the format of this JSON file!<br><br>Error detail: <br>";
errorContent.innerHTML = errorString + e;
$('#errorModal').modal({inverted: true}).modal('show');
return "error";
}
} else
data = graphData + JSON.stringify(options);

Expand Down Expand Up @@ -147,10 +156,14 @@ let processNodes = async function () {
}
else {
if(res && res.errorMessage) {
alert(res.errorMessage);
let errorContent = document.getElementById("errorContent");
errorContent.innerHTML = res.errorMessage;
$('#errorModal').modal({inverted: true}).modal('show');
}
else {
alert("Sorry! Cannot process the given file!");
let errorContent = document.getElementById("errorContent");
errorContent.innerHTML = "<b>Sorry! Cannot process the given file!</b>";
$('#errorModal').modal({inverted: true}).modal('show');
}
return "error";
}
Expand Down Expand Up @@ -280,7 +293,9 @@ let processLayout = async function () {
return result;
})
.catch(e => {
return alert("Sorry! Cannot process the given file!");
let errorContent = document.getElementById("errorContent");
errorContent.innerHTML = "<b>Sorry! Cannot process the given file!</b><br><br>Error detail:<br>" + e;
$('#errorModal').modal({inverted: true}).modal('show');
});

$("#applyLayout").removeClass("loading");
Expand All @@ -299,10 +314,14 @@ let processLayout = async function () {
}
else {
if(res.errorMessage) {
alert(res.errorMessage);
let errorContent = document.getElementById("errorContent");
errorContent.innerHTML = res.errorMessage;
$('#errorModal').modal({inverted: true}).modal('show');
}
else {
alert("Sorry! Cannot process the given file!");
let errorContent = document.getElementById("errorContent");
errorContent.innerHTML = "<b>Sorry! Cannot process the given file!</b>";
$('#errorModal').modal({inverted: true}).modal('show');
}
}
};
Expand Down
Loading

0 comments on commit 5fd7cdf

Please sign in to comment.