Coder Social home page Coder Social logo

Comments (3)

aron avatar aron commented on May 27, 2024

I've added a friendlier notifications to the Annotator class (perhaps it should reside in a separate object?) and added some error messages for various response statuses.

However it's looking like the XMLHTTPRequest object is not updated in either WebKit or Firefox if the request is not successful. This results in a status code of 0 (which jQuery normalises to 302).

Example

var xhr = new XMLHttpRequest();

xhr.open('GET', 'http://localhost:5000/annotations/21', true);
xhr.onreadystatechange = function () {
  console.log("%o %o", xhr.status, xhr.responseText, xhr)
};
xhr.send();

So unless anyone has any thoughts? It looks like we're only able to provide very generic error messages, which is a shame.

from annotator.

aron avatar aron commented on May 27, 2024

Another option that may be worth considering is to detect the Annotator (using a custom HTTP header) and then always return a successful response but override the status in a similar way to method overloading in web frameworks.

For example an invalid authorisation would return

HTTP/1.1 200 OK
X-HTTP-Status-Override: 401 Unauthorized

Although this may not be worth the effort involved in updating the store.

from annotator.

aron avatar aron commented on May 27, 2024

Closing this ticket. CORS error handling may need to be ticketed for improvement at a later date.

Current state is that Annotation.showNotification() displays a message fixed to the top of the users screen with the current error message. The notification can be removed on click or will hide itself after five seconds.

Generic error messages are:

"Sorry we could not #{action} the annotations from the store"

if the request affects more than one annotation and

"Sorry we could not #{action} this annotation"

where it affects just one. #{action} will be replaced with the current action eg. read, update, delete etc.

When we get a definite status from the server:

401 Unauthorised: "Sorry you are not allowed to #{action} this annotation"
404 Not Found: "Sorry we could not connect to the annotations store"
500 Internal Server Error: "Sorry something went wrong with the annotation store"

In future it would be useful to return more specific errors from the annotation store.

from annotator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.