Skip to content

Commit

Permalink
handle bundle failures nicely
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 4, 2015
1 parent 9842055 commit 9ae58d0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions nikola/plugins/task/bundles.py
Expand Up @@ -43,11 +43,12 @@ class BuildBundles(LateTask):
name = "create_bundles"

def set_site(self, site):
super(BuildBundles, self).set_site(site)
self.logger = utils.get_logger('bundles', site.loghandlers)
if webassets is None and self.site.config['USE_BUNDLES']:
utils.req_missing(['webassets'], 'USE_BUNDLES', optional=True)
utils.LOGGER.warn('Setting USE_BUNDLES to False.')
self.logger.warn('Setting USE_BUNDLES to False.')
self.site.config['USE_BUNDLES'] = False
super(BuildBundles, self).set_site(site)

def gen_tasks(self):
"""Bundle assets using WebAssets."""
Expand All @@ -74,7 +75,12 @@ def build_bundle(output, inputs):
bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
env.register(output, bundle)
# This generates the file
env[output].urls()
try:
env[output].urls()
except Exception as e:
self.logger.error("Failed to build bundles.")
self.logger.exception(e)
self.logger.notice("Try running ``nikola clean`` and building again.")
else:
with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):
pass # Create empty file
Expand Down

0 comments on commit 9ae58d0

Please sign in to comment.