Skip to content
This repository was archived by the owner on Nov 9, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
buildscript {
repositories {
maven { url "http://repo1.maven.org/maven2" }
maven { url "http://developer.marklogic.com/maven2/" }
maven { url "https://repo1.maven.org/maven2" }
maven { url "https://developer.marklogic.com/maven2/" }
}

dependencies {
Expand All @@ -14,7 +14,7 @@ buildscript {
plugins {
id "java"
id "net.saliman.properties" version "1.4.6"
id "com.marklogic.ml-gradle" version "3.6.2"
id "com.marklogic.ml-gradle" version "3.17.0"
id "idea"
}

Expand All @@ -31,7 +31,7 @@ dependencies {
testCompile "org.gradle:gradle-tooling-api:4.3"
testCompile "commons-io:commons-io:2.6"

compile "com.marklogic:ml-app-deployer:3.9.0"
compile "com.marklogic:ml-app-deployer:3.17.0"

// For reading command-line args
compile "com.beust:jcommander:1.72"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,19 @@ angular.module('demoApp')
renderResultsModal('success', crudType + crudAction + 'successfully.');
$rootScope.noQueries = false;
}
}).error(function(data, status){
renderResultsModal('error', 'Server Error. Please try again later.');
}).error(function(response, status){
// default error message in case we don't understand what is returned
let errorMessage = 'Error: Please try again later.';

// Create a better error message if we can
if(response.hasOwnProperty("error") && response.error.length > 0){
if(response.error[0].code === 'XDMP-NODB'){
errorMessage = "Error: Database '" + data.database + "' does not have a schemas database associated with it.";
}else {
errorMessage = "Error: " + response.error[0].code + ": " + response.error[0].message;
}
}
renderResultsModal('error', errorMessage);
});
}
};
Expand Down
33 changes: 9 additions & 24 deletions src/main/ml-modules/root/server/error.xqy
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,15 @@ xquery version "1.0-ml";

import module namespace cfg = "http://www.marklogic.com/data-explore/lib/config" at "/server/lib/config.xqy";
import module namespace check-user-lib = "http://www.marklogic.com/data-explore/lib/check-user-lib" at "/server/lib/check-user-lib.xqy";
import module namespace json="http://marklogic.com/xdmp/json" at "/MarkLogic/json/json.xqy";

declare namespace error = "http://marklogic.com/xdmp/error";
declare option xdmp:mapping "false";
declare variable $error:errors as node()* external;

xdmp:set-response-content-type("text/html"),
'<!DOCTYPE html>',
<html>
<head>
<title>{$cfg:app-title} - Error</title>
<!--<link href="/css/status.css" type="text/css" rel="stylesheet"/>-->
</head>
<body>
<div id="container">
<div id="header">
<a href="/"><h1>{$cfg:app-title}</h1></a>
<!--div id="headerImg"/-->
<br class="floatclear"/>
</div>
<div id="body" class="contentfull">
<div class="section" id="dbcontent">
<h2>Error </h2>
<p>There has been an error.</p>
<p>{xdmp:quote($error:errors)}</p>
</div>
</div>
</div>
</body>
</html>
let $config := json:config("custom")
let $_ := map:put($config, "array-element-names", (xs:QName("error:error"), xs:QName("error:stack"),xs:QName("error:frame"), xs:QName("error:variable")))
return (
xdmp:set-response-content-type("application/json"),
json:transform-to-json($error:errors, $config)
)