Awesome ASP.net Core and MVC Controls

Error handling demo

When a JavaScript error happens because of server error/incorrect url (500, 404) the only way you would know the reason is by using something like firebug/chrome dev tools (by looking in the console for the execution of ajax requests).

You can also assign a js function to the awe.err, this way whenever an error will occur your custom function will be executed (this code is called in utils.init).
utils.js
awe.err = function (o, p2) {
var msg = "unexpected error occured";
if (p2) {
if (typeof p2 === 'string') {
msg = p2;
} else {
msg = p2.responseText || msg;
}
}

var content = msg;
// handle ajax errors that return html with layout page
if (msg.indexOf('<html>') > -1) {
content = $('<div>unexpected error<br/> (showing it will replace the whole page)<div/>');
var btn = $('<a href="">show</a>').click(function (e) {
e.preventDefault();
$('body').html(msg);
});

content.append(btn);
}

awem.notif(content, 0, 'o-err');

// close popup that got error
if (o && o.p && o.p.isOpen) {
dapi(o.p.d).close();
}
};

Error on popup open

clicking on this popup links will throw a server exception, click on them to see how it's handled

Error on popup form post




Comments

We use cookies to improve your online experience. By accessing this site, you agree to the use of cookies and other technologies to process your personal data (e.g. IP address) to enhance and personalise your experience across our websites. Additionally, third-party companies, may store cookies on your device and use similar technologies to collect and use certain information. For more information, refer to our privacy policy and cookie policy.