-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
Delegate error printing to the ajax caller. #2142
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome... Great cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, one thought...
} | ||
|
||
$.console.error(msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not write to the console here if somebody has subscribed to the open-failed
event? We may need to add something like hasHandler
to EventSource
to make that possible, but it shouldn't be hard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, maybe not... The problem is open-failed
event is registered inside OpenSeadragon to print the message into the error html container, so in 99,9999% scenarios this equals to not logging the message at all...
I found out while adding test case for this commit (yeah, should do it in one commit) that OSD actually uses the event internally, so the event handler count is almost always > 0 and therefore the error gets never printed... I would revert the last commit and just go with it as it was... I mean 'open' event happens once per tile source, so it is not that big a problem, unlike the image tile fetching itself. What do you think? |
Good catch! Yeah, please undo that change. Might as well keep |
…w message style. Add 'numberOfHandlers()' method for events.
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! Thank you for the tests for numberOfHandlers
:)
By default, OSD prints an error if ajax call results in an error response code (other than
2xx
). This is a bit problematic since one can use custom error codes to route the behaviour and the console gets bloated by unnecessary error messages (I am having a scenario where tiles are expected to be very unpredictable, and the system can automatically detect that and remove the tiled image: having hundreds identical errors in the console does not help much). Other problem is that each error response generates two error messages, following the how not to scenario:so the ajax function should print an error only if no error handler is registered, otherwise, it should be the handler's responsibility to do so. Following the future PR I am planning, the user will have also the ability to re-define how tiles are downloaded and thus control the errors completely.