mirror of
https://github.com/wavetermdev/homebrew-cask.git
synced 2026-08-05 13:43:24 -07:00
Merge pull request #4673 from rolandwalker/cask_load_exceptions
Improve error checking and messages on Cask load
This commit is contained in:
@@ -15,8 +15,23 @@ class Cask::Source::PathBase
|
||||
end
|
||||
|
||||
def load
|
||||
require path
|
||||
Cask.const_get(cask_class_name).new
|
||||
raise CaskError.new "File '#{path}' does not exist" unless path.exist?
|
||||
raise CaskError.new "File '#{path}' is not readable" unless path.readable?
|
||||
raise CaskError.new "File '#{path}' is not a plain file" unless path.file?
|
||||
begin
|
||||
require path
|
||||
rescue CaskError, StandardError, ScriptError => e
|
||||
# bug: e.message.concat doesn't work with CaskError exceptions
|
||||
e.message.concat(" while loading '#{path}'")
|
||||
raise e
|
||||
end
|
||||
begin
|
||||
Cask.const_get(cask_class_name).new
|
||||
rescue CaskError, StandardError, ScriptError => e
|
||||
# bug: e.message.concat doesn't work with CaskError exceptions
|
||||
e.message.concat(" while instantiating '#{cask_class_name}' from '#{path}'")
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
||||
def cask_class_name
|
||||
|
||||
@@ -14,10 +14,12 @@ class Cask::Source::URI
|
||||
path = HOMEBREW_CACHE_CASKS.join(File.basename(uri))
|
||||
ohai "Downloading #{uri}"
|
||||
odebug "Download target -> #{path.to_s}"
|
||||
curl(uri, '-o', path.to_s)
|
||||
begin
|
||||
curl(uri, '-o', path.to_s)
|
||||
rescue ErrorDuringExecution
|
||||
raise CaskUnavailableError.new uri
|
||||
end
|
||||
Cask::Source::PathSlashOptional.new(path).load
|
||||
rescue ErrorDuringExecution
|
||||
raise CaskUnavailableError, uri
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
||||
Reference in New Issue
Block a user