Skip to content

Commit 010b66b

Browse files
committed
Replace the solution to include the package name in the error message, like in other similar logs messages
1 parent 0f1a5e8 commit 010b66b

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

spec/integration/install_spec.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ describe "install" do
855855
with_shard(metadata) do
856856
ex = expect_raises(FailedCommand) { run "shards install --no-color" }
857857
ex.stdout.should contain <<-ERROR
858-
E: Failed to install `executable_missing`: Could not find executable "nonexistent"
858+
E: Could not find executable "nonexistent" for "executable_missing"
859859
ERROR
860860
end
861861
end

src/cli.cr

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,6 @@ rescue ex : OptionParser::InvalidOption
181181
rescue ex : Shards::ParseError
182182
ex.to_s(STDERR)
183183
exit 1
184-
rescue ex : Shards::Package::Error
185-
package = ex.package
186-
Shards::Log.error(exception: ex) { "Failed to install `#{package.name}`: #{ex.message}" }
187-
exit 1
188184
rescue ex : Shards::Error
189185
Shards::Log.error(exception: ex) { ex.message }
190186
exit 1

src/package.cr

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ require "./helpers"
33

44
module Shards
55
class Package
6-
class Error < Shards::Error
7-
getter package
8-
9-
def initialize(message, @package : Package)
10-
super message
11-
end
12-
end
13-
146
getter name : String
157
getter resolver : Resolver
168
getter version : Version
@@ -122,7 +114,7 @@ module Shards
122114
spec.executables.each do |name|
123115
exe_name = find_executable_file(Path[install_path], name)
124116
unless exe_name
125-
raise Shards::Package::Error.new("Could not find executable #{name.inspect}", package: self)
117+
raise Shards::Error.new("Could not find executable #{name.inspect} for #{@name.inspect}")
126118
end
127119
Log.debug { "Install #{exe_name}" }
128120
source = File.join(install_path, exe_name)

0 commit comments

Comments
 (0)