Can you suggest a better way of Reporting Errors?

S

Stor Ursa

I'm looking for a good way of handling errors after an asynchronous
call.

Currently I have a model view controller set up in javascript.

the view is the DOM
the Controller manipulates the DOM / Handle Events Fire From the DOM
the Model performs processing requests and responses from the back
end, and maintains state variables, like current search page.

I'm looking for a good way of reporting errors that come from the back
end, while maintaining the MVC. The outline of my code below is the
best way I can think of right now.

Can you guys suggest anything better?

Sample Code.

Model.prototype.search = function() {
try {
this.controller.gatherSearchParams();
} catch(error) {
this.controller.reportError(error.description);
}
this.sendRequest(this.url, this.params, this.searchCompleted);
};

Model.prototype.searchComplete = function(response) {
if(this.ResponseHelper.containsError(response)) {
this.controller.reportError(this.ResponseHelper.getErrorMsg
(response));
}
};
 
D

dhtml

Stor said:
I'm looking for a good way of handling errors after an asynchronous
call.

Currently I have a model view controller set up in javascript.

the view is the DOM

DOM stands for Document Object Model.

The DOM is the Model.

Reconsider your approach.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top