-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Remove goog.asserts.* #5619
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
Remove goog.asserts.* #5619
Conversation
d5b4f91 to
629a52c
Compare
src/ol/ol.js
Outdated
|
|
||
| /** | ||
| * Error code. The meaning of the code can be found on | ||
| * {@link http://openlayers.org/en/lates/errors.html} (replace `latest` with |
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.
/lates/latest/
629a52c to
3987b68
Compare
src/ol/feature.js
Outdated
| } else { | ||
| goog.asserts.assertInstanceof(obj, ol.style.Style, | ||
| 'obj should be an ol.style.Style'); | ||
| ol.assert(obj instanceof ol.style.Style, 41); |
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.
you might want to add the error as a comment here too
|
ISTM there's 2 types of runtime errors, which need to be handled differently. Most of them catch application errors; in this case, the developer should see the error when testing the app, and correct the problem. But some of them catch data errors, like problems with vector files. These may be user-supplied and beyond the developer's control, so the developer has to catch these, and inform the user. It might be worth having a different error type or process for these, but in any case developers need to consider how to handle them. I think this has to be documented and mentioned in the release notes. |
3987b68 to
4c355d9
Compare
|
@probins The lines between the two are blurry, so I decided to not introduce two error types. Think of someone reading in WMC context files or some other user provided map configurations. In this case, configuration errors can occur in a context that is beyond the app developer's influence. But I agree that this change in general needs to be mentioned in the release notes. I'm going to add that. |
083d386 to
f0d3183
Compare
|
ok. I'd also document the console.asserts. Something like 'There are additional console assertion checks when in debug mode (when the new |
f0d3183 to
d920e4d
Compare
|
Good suggestion. Done. |
d28314d to
a60c282
Compare
src/ol/ol.js
Outdated
| */ | ||
| this.message = 'Assertion failed. See ' + | ||
| (ol.VERSION ? 'http://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') + | ||
| '/doc/errors.html#' + code + ' for details.'; |
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.
URL snob comment: how about openlayers.org/en/latest/errors/#123 instead (adding doc/errors/index.md instead of doc/errors.md?
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.
Sounds reasonable. I'll make that change. Thanks for the suggestion 😄.
a60c282 to
b8b93af
Compare
changelog/upgrade-notes.md
Outdated
|
|
||
| #### Changes in the way assertions are handled | ||
|
|
||
| Previously, minified builds of the library did not have any assertions. This caused applications to fail silently or with cryptic stack traces. Starting with this release, developers get notified of many runtime errors through the new `ol.AssertionError`. This error has a `code` property. The meaning of the code can be found on http://openlayers.org/en/latest/doc/errors/. There are additional console assertion checks when in debug mode when the new `ol.DEBUG` compiler flag (previously `goog.DEBUG`) is `true`. As this is `true` by default, it is recommended that those creating custom builds set this to `false` so these assertions are stripped.' |
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.
There is still a lot of goog.DEBUG in the library (and our build configs). Would it make sense to switch to ol.DEBUG when the rest of goog is gone? With this branch, I assume a build config would have to set both to false to remove debug code.
|
Wow. Thanks for taking this on @ahocevar. What do you think about leaving |
|
@tschaub I have renamed |
5960d7d to
2fdd8a3
Compare
This pull requests replaces type check hint assertions with type casts, library sanity check assertions with conditional console.assert statements in debug mode, and runtime sanity checks with assertions that throw an ol.AssertionError with an error code for lookup outside the library.
2fdd8a3 to
bf275b0
Compare
|
Very nice. Merge it! |
|
Thanks for the review and the good suggestions @tschaub. |
|
👏 removing the 'gratuitous' asserts is a considerable simplification. That's the biggest outstanding part of the Closure library. Just remains a few bits and pieces ... |
|
this creates a whole lot of extra |
|
@probins Thanks for willing to take this on! Before renaming |
This pull requests replaces type check hint assertions with type casts, library sanity check assertions with conditional console.assert statements in debug mode, and runtime sanity checks with assertions that throw an ol.AssertionError with an error code for lookup outside the library.
See #5600.
There is one remaining
goog.asserts.assertInstanceof, for which there is a separate pull request (#5616).Fixes #5619.