Comments (5)
I'm fine with improving the error, though I'm -1 on silencing it. I know that Django traditionally has a policy of ignoring errors in templates, though IIRC from discussions on django-dev, at this point even the Django devs feel conflicted about this.
Is there a particular use case you have in mind where a missing file is not a bug that the developer would want to be notified about?
from webassets.
No, there is no special use case. I just think that getting HTTP 500 errors because of a mispelled js file path is not right.
Even in the development environment, when I misspell a js file path, and I'm not using webassets, I'll be noticed about that by a 404 error or a javascript console error on my browser developers tools, not by a TemplateSyntaxError nor IOError on the server side. So I thought that webassets should act this way.
from webassets.
The browser ignores files it can't load, but that's not to say that a separate preprocessing step on the server like webassets needs to persist that behavior. I guess I just don't see the advantage.
It makes sense for the browser to ignore the files it can't find and still display a site, because that still gives the user something, which is better than showing nothing. On the other hand, as a developer, I want to be made aware of an error like that as prominently as possible; everything else is just going to cost me more time trying to find a bug.
Now, there's a chance that such an error could trickle down to the user if the developer where to deploy a buggy site, but ideally, that wouldn't happen (and raising a big fat error is going to help that it won't), and I'd say the benefits outweigh the costs.
Anyway, I might be willing to include an option to toggle on a silent-error behavior if it turns out a lot of people want it. Feedback welcome.
from webassets.
I think hiding the error is the wrong thing to do, specially considering that once the assets are packaged it's damn difficult to check if a script has been included or not. At least a nice warning should be shown in development, and maybe even stop the bundling in production unless you expressely specify an option in the configuration file or command line.
I think hiding the error misses the principle of 'least surprise' that Django is based on. If you are old enough to remember the 'magic-removal branch' you know what I mean.
from webassets.
I'm closing this for now. I just had a look at implementing a custom exception type with a custom error message, but there's really no good solution. There's actually different OSErrors that could be raised, either by the code that checks whether the bundle needs to be rebuilt and thus needs to look at the source file timestamps, or the code that tries to do the actual building. There are going to be more in the future. I don't really want to handle all these cases separately.
On the other hand, you can't really check the filenames for existance earlier. It has potential performance implications, and isn't correct either. For example, if a path were checked once it is added to the bundle, that same file may no longer exist when the build happens (i.e. it'd be effectively a race condition). This might mostly be an academic distinction, but still.
In the end "OSError: file XYZ does not exist", together with the stack trace that clearly points into the webassets library, should be a clear enough indication of what's wrong.
from webassets.
Related Issues (20)
- jsmin/rjsmin removes blanks in ES6 Template Strings HOT 1
- Fail when packing an external resource HOT 4
- YAMLLoadWarning yaml.load is deprecated
- Bundles cannot be replaced/re-added
- --line-comments is deprecated
- LibSASS - Unable to use other compile options like source_comments
- Version 2: Couldn't find preset HOT 3
- Threading.isAlive was removed in Python 3.9
- Load_builtin_filters doesn't work as expected with PyInstaller
- Deprecation warning due to invalid escape sequences in Python 3.7
- Fix simple typo: ultimatily -> ultimately
- Closure: ReferenceError: $jscomp is not defined
- Copy assets
- SCSS filter runs command sass without --scss HOT 2
- Add a tool to remove unused css
- How to configure filters using the YAML config option? Specifically cssrewrite. HOT 1
- Jinja2 Base template loaded twice when upgrading werkzeug package
- Add a way to get all bundle names
- 'out' is deprecated and will stop functioning in TypeScript 5.5
- mode merge=False not implemented in flask_assets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webassets.