Creating a generic UI error handling mechanism
This commit is contained in:
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);
|
||||
};
|
||||
Reference in new issue
Block a user