How To Override AJAX error handlers

4147
2
12-03-2015 01:40 PM
BrianBehling
New Contributor III

Is it possible to override all task request (AJAX) error handlers? This would be for all tasks such as Query or Identify tasks.

I need to add specific actions to the error handlers and do not wish to manually add this to all existing error callback code.

EDIT -

Found this solution using Dojo ioPublish

IO Pipeline Topics — The Dojo Toolkit - Reference Guide

Which does work. However, this stackexchange post says that extr overrhead is incurred using ioPublish.

http://stackoverflow.com/questions/4781018/dojo-intercepting-xhr-calls

So I guess now the question is, will extra over head be incurred if only subscribing to the error topic?

EDIT 2 -

Turns out ioPublish error handler does not catch 401 errors. ESRI, please provide a solution for a global error handler.

0 Kudos
2 Replies
thejuskambi
Occasional Contributor III

Hello Brian,

why dont you simply make a single global Error handling function, pass that as your error callback for all your task request. This will work if you dont have any task specific error handler. otherwise, you can just call the global error handling function in each of your error callbacks.

Hope this was helpful.

Warm Regards,

Thejus

0 Kudos
BrianBehling
New Contributor III

Thanks for the response, but that defeats the whole purpose of what I'm trying to accomplish.

I do not want to go into each and every error handler in this project and add new code to the error handlers. With jQuery, its as simple as

$(document).ajaxError(function (event, jqxhr, settings, thrownError) {

            });

0 Kudos