Correctly propagate frontend call warnings (fixes #211)
Change-Id: Ia571b8e6b0ba0a4edbf0501254ce2bc115f18cf6
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index 80391d8..3b3b821 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -169,10 +169,16 @@
return;
};
- if (retJSObj !== undefined && retJSObj["errors"] !== undefined) {
- retJSObj["errors"].forEach(
- e => KorAP.log(e[0], e[1] || "Unknown")
- );
+ if (retJSObj !== undefined) {
+ if (retJSObj["errors"] !== undefined) {
+ retJSObj["errors"].forEach(
+ e => KorAP.log(e[0], e[1] || "Unknown")
+ );
+ } else if (retJSObj["warnings"] !== undefined) {
+ retJSObj["warnings"].forEach(
+ e => KorAP.log(e[0], e[1] || "Unknown", null, 'warn')
+ );
+ }
}
else if (this.status !== 200) {
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 6243bc7..6e6b4f1 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -56,7 +56,7 @@
// Override KorAP.log
window.alertify = alertifyClass;
- KorAP.log = function (code, msg, src) {
+ KorAP.log = function (code, msg, src, type) {
if (src) {
msg += '<code class="src">'+src+'</code>';
@@ -66,7 +66,7 @@
alertifyClass.log(
(code === 0 ? '' : code + ': ') +
msg,
- 'error',
+ (type ? type : 'error'),
10000
);
};