mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 07:08:12 +00:00
[persistence] #58 added tests for notification on persistence error
This commit is contained in:
@ -89,16 +89,28 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
function formatError(error){
|
||||
if (error && error.message) {
|
||||
return error.message;
|
||||
} else if (error && typeof error === "string"){
|
||||
return error;
|
||||
} else {
|
||||
return "unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a notification message if an error has occurred during
|
||||
* persistence.
|
||||
*/
|
||||
function notifyOnError(error, domainObject, notificationService, $q){
|
||||
var errorMessage = "Unable to persist " + domainObject.model.name + ": ";
|
||||
errorMessage += typeof error === "string" ? error : error.message;
|
||||
var errorMessage = "Unable to persist " + domainObject.getModel().name;
|
||||
if (error) {
|
||||
errorMessage += ": " + formatError(error);
|
||||
}
|
||||
|
||||
notificationService.error({
|
||||
title: "Error persisting " + domainObject.model.name,
|
||||
title: "Error persisting " + domainObject.getModel().name,
|
||||
hint: errorMessage || "Unknown error"
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user