Creating a generic UI error handling mechanism

This commit is contained in:
Bruno Alves de Faria committed 2018-02-27 07:12:23 -03:00
1 parent 3c1e4c51cd
commit 798b197d4a
13 files changed
+81 -9

No files matched your search

@@ -0,0 +1,33 @@
import { Meteor } from 'meteor/meteor';
import { OHIF } from 'meteor/ohif:core';
OHIF.ui.handleError = error => {
let { title, message } = error;
if (!title) {
if (error instanceof Meteor.Error) {
title = error.error;
} else if (error instanceof Error) {
title = error.name;
}
}
if (!message) {
if (error instanceof Meteor.Error) {
message = error.reason;
} else if (error instanceof Error) {
message = error.message;
}
}
const data = Object.assign({
title,
message,
class: 'themed',
hideConfirm: true,
cancelLabel: 'Dismiss',
cancelClass: 'btn-secondary'
}, error || {});
OHIF.ui.showDialog('dialogForm', data);
};