Reputation: 2022
during Save changes, there are instance when validation is failing, but how do i get back and display the actual Error Message. The saveFailed function is executed, but i want more details information, about what validations failed and those individual error emssages
function saveChanges() {
if (manager.hasChanges()) {
manager.saveChanges()
.then(saveSucceeded)
.fail(saveFailed);
} else {
alert("Nothing to save");
};
};
function saveSucceeded() {
alert("changes saved successfully");
};
function saveFailed(error) {
alert("Error while saving changes" + error.message);
};
Upvotes: 1
Views: 1502
Reputation: 380
Have a look at the TODO sample that is provided with the breeze download.
The dataservice.js clearly shows you how to catch and display validation errors.
Upvotes: 1
Reputation: 17052
The 'error' object returned by the fail handler, should contain additional details, depending on the error. The following properties should always be there
error.message - the error message error.status - http error code - usually a 400 or 500 code error.detail - any details relevant to the error error.XHR - the raw XML HttpResponse object error.responseText
For validation errors, right now they appear in the error.message, but we are looking at breaking them out in a cleaner fashion, possibly into another property. But for now they will appear in the error.message.
Upvotes: 0