Browse files

More explicit cache loading errors

  • Loading branch information...
1 parent a7d3322 commit 0da9d8e1ed23a5e3d3eee5645f78c7179804bbab @josh josh committed Nov 2, 2011
View
4 lib/sprockets/asset.rb
@@ -24,9 +24,7 @@ def self.from_hash(environment, hash)
asset.init_with(environment, hash)
asset
end
-
- # TODO: Think long and hard about this
- rescue Exception
+ rescue UnserializeError
nil
end
View
2 lib/sprockets/asset_attributes.rb
@@ -34,7 +34,7 @@ def search_paths
def logical_path
if root_path = environment.paths.detect { |path| pathname.to_s[path] }
path = pathname.to_s.sub("#{root_path}/", '')
- # path = pathname.relative_path_from(Pathname.new(root_path)).to_s
+ path = pathname.relative_path_from(Pathname.new(root_path)).to_s
path = engine_extensions.inject(path) { |p, ext| p.sub(ext, '') }
path = "#{path}#{engine_format_extension}" unless format_extension
path
View
4 lib/sprockets/bundled_asset.rb
@@ -39,7 +39,7 @@ def init_with(environment, coder)
@required_assets = @processed_asset.required_assets
if @processed_asset.digest != coder['self_digest']
- @processed_asset = nil
+ raise UnserializeError, "processed asset belongs to a stale environment"
end
@source = coder['source']
@@ -73,7 +73,7 @@ def to_a
# Checks if Asset is stale by comparing the actual mtime and
# digest to the inmemory model.
def fresh?(environment)
- @processed_asset && @processed_asset.fresh?(environment)
+ @processed_asset.fresh?(environment)
end
end
end
View
1 lib/sprockets/errors.rb
@@ -7,6 +7,7 @@ class ContentTypeMismatch < Error; end
class EncodingError < Error; end
class FileNotFound < Error; end
class FileOutsidePaths < Error; end
+ class UnserializeError < Error; end
module EngineError
attr_accessor :sprockets_annotation
View
5 lib/sprockets/processed_asset.rb
@@ -27,6 +27,11 @@ def init_with(environment, coder)
@source = coder['source']
@required_assets = coder['required_paths'].map { |p|
p = expand_root_path(p)
+
+ unless environment.paths.detect { |path| p[path] }
+ raise UnserializeError, "#{p} isn't in paths"
+ end
+
p == pathname.to_s ? self : environment.find_asset(p, :bundle => false)
}
@dependency_paths = coder['dependency_paths'].map { |h|

0 comments on commit 0da9d8e

Please sign in to comment.