Skip to content

Commit

Permalink
Properly show message if failure
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthieuBarba committed Mar 2, 2024
1 parent 01d5bc6 commit aae83fe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
//import { check_data_error } from "./utils.js";

function print_db() {
pars = {};
pars.type = 'databases';
var str = "in print_db";
console.log(str);
console.log(format_url(urls.get_data, pars));
$.getJSON( urls.get_data, pars, function(data) {
error_msg = check_data_error(data);
if (error_msg) {
$( "#databases" ).append( error_msg );
} else {
print_db_table(data);
}
}).fail(function(){
console.log("Failed databases retrieval");
});
}

function check_data_error( data ) {
error_msg = ""
if ("outcome" in data && data["outcome"] == false) {
console.log("Error occurred: " + data["details"]);
error_msg = $("<p />").text("An error occurred: " + data["message"] + ". Check the console for more details.");
}
return error_msg;
}

function get_dbs() {
var dbs = {};

Expand Down

0 comments on commit aae83fe

Please sign in to comment.