Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the error modal for API errors as well #1976

Merged
merged 6 commits into from
Aug 25, 2017
Merged

Use the error modal for API errors as well #1976

merged 6 commits into from
Aug 25, 2017

Conversation

himdel
Copy link
Contributor

@himdel himdel commented Aug 22, 2017

Right now, we have an error modal component, which we trigger when an angular ajax request fails - but only for requests made via angular's $http.

Now that we're moving to use the API more and more, we also need to see those errors if they're coming from the API.

Thus, this enhances the error modal to:

  • work for all API requests, unless called with noErrorModal
  • show the request type in the header (API vs $http)
  • show the request URL

To prevent the error modal on API request when such is not desired (for example, when a 404 is a valid response that the client code can handle), this makes it possible to call those methods as API.get.noErrorModal(url) instead of API.get(url) and not see the error. (This works for all the request methods, not just get.)


An API request failing (this is new):

api_error

A $http request failing (this worked before, but didn't show the url (or the type)):

http_error

@himdel
Copy link
Contributor Author

himdel commented Aug 22, 2017

Cc @dclarizio, you asked for it :)

@dclarizio
Copy link

@himdel at least 2 of the codeclimate issues look fixable :) Also, can you suggest a reviewer? Thx, Dan

himdel added 6 commits August 24, 2017 16:02
Right now, all the API requests need to handle errors where called.
That should still be true, but we also want to show an error modal on server errors, including the API.

Thus, triggering the error modal when the server response is no 2**.
this is mostly so that we can differentiate between the two kinds of requests and handle their specifics appropriately

but also showing it in the modal title
this way, doing `API.get(url)` always triggers the error modal on error,
but now this can be skipped by using `API.get.noErrorModal(url)` instead.

The same goes for all the other methods.
…tch/$http differences there

getting at the headers is diffent, need to store contentType outside

also, $http errors contain both the response and the metadata, while fetch errors contain only the metadata and async methods to get at the response itself - thus this changes the error objects coming from the API to contain everything needed
@himdel
Copy link
Contributor Author

himdel commented Aug 24, 2017

at least 2 of the codeclimate issues look fixable :)

Thanks, fixed all 3 :).

Also, can you suggest a reviewer? Thx, Dan

I guess @mzazrivec maybe? :)

@miq-bot
Copy link
Member

miq-bot commented Aug 24, 2017

Checked commits https://github.com/himdel/manageiq-ui-classic/compare/3c9fe45f8ef0b7d33fe27e5d56bc2a297c9f8692~...d3f005549992c5d6d02faefdf37329568bc7a1fa with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
0 files checked, 0 offenses detected
Everything looks fine. 🍪

@mzazrivec
Copy link
Contributor

The code looks good and things seem to be working nicely in the UI.

Than you @himdel for being a wonderful human being (and coder).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants