Why isn't the onError handler firing in the Http.call() future?

Viewed 209

I'm attempting to make a web request using the Http service. The request is failing (as expected) and returning a 403. I would expect that the onError handler would execute, but it's not. An exception is thrown and never caught.

_http(url: '/widgets/shiny-trinket', method: 'PUT', data: 'some malformed data')
  .then((resp) => successHandler, 
  onError: (resp) {
    // why aren't we getting here?
    displayErrorMessage();
  });

The exception that's thrown (from the console):

Failed to load resource: the server responded with a status of 403 (Forbidden)
  http://localhost/widgets/shiny-trinket
Instance of '_XMLHttpRequestProgressEvent'

STACKTRACE:
null

Am I doing something wrong? Or is this a bug?

UPDATE

I've also tried the following, and it also doesn't work.

_http(url: '/widgets/shiny-trinket', method: 'PUT', data: 'some malformed data')
  .then((resp) => successHandler) 
  .catchError((e) {
    // why aren't we getting here?
    displayErrorMessage();
  });
2 Answers
Related