File tree 4 files changed +30
-13
lines changed 4 files changed +30
-13
lines changed Original file line number Diff line number Diff line change @@ -176,12 +176,18 @@ end
176
176
begin
177
177
Shards .run
178
178
rescue ex : OptionParser ::InvalidOption
179
- Shards ::Log .fatal { ex.message }
179
+ Shards ::Log .fatal( exception: ex) { ex.message }
180
180
exit 1
181
181
rescue ex : Shards ::ParseError
182
182
ex.to_s(STDERR )
183
183
exit 1
184
+ rescue ex : Shards ::PackageError
185
+ package = ex.package
186
+ Shards ::Log .error(exception: ex) { " Failed to install `#{ package.name } `: #{ ex.message } " }
187
+ Shards ::Log .debug { ex.inspect_with_backtrace }
188
+ exit 1
184
189
rescue ex : Shards ::Error
185
- Shards ::Log .error { ex.message }
190
+ Shards ::Log .error(exception: ex) { ex.message }
191
+ Shards ::Log .debug { ex.inspect_with_backtrace }
186
192
exit 1
187
193
end
Original file line number Diff line number Diff line change @@ -65,16 +65,19 @@ module Shards
65
65
# packages are returned by the solver in reverse topological order,
66
66
# so transitive dependencies are installed first
67
67
packages.each do |package |
68
- # first install the dependency:
69
- next unless install(package)
70
-
71
- # then execute the postinstall script
72
- # (with access to all transitive dependencies):
73
- package.postinstall
74
-
75
- # always install executables because the path resolver never actually
76
- # installs dependencies:
77
- package.install_executables
68
+ Log .with_context do
69
+ Log .context.set package: package.name
70
+ # first install the dependency:
71
+ next unless install(package)
72
+
73
+ # then execute the postinstall script
74
+ # (with access to all transitive dependencies):
75
+ package.postinstall
76
+
77
+ # always install executables because the path resolver never actually
78
+ # installs dependencies:
79
+ package.install_executables
80
+ end
78
81
end
79
82
end
80
83
Original file line number Diff line number Diff line change @@ -2,6 +2,14 @@ module Shards
2
2
class Error < ::Exception
3
3
end
4
4
5
+ class PackageError < Error
6
+ getter package
7
+
8
+ def initialize (message, @package : Package )
9
+ super message
10
+ end
11
+ end
12
+
5
13
class Conflict < Error
6
14
getter package
7
15
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ module Shards
114
114
spec.executables.each do |name |
115
115
exe_name = find_executable_file(Path [install_path], name)
116
116
unless exe_name
117
- raise Shards ::Error .new(" Could not find executable #{ name.inspect } " )
117
+ raise Shards ::PackageError .new(" Could not find executable #{ name.inspect } " , package: self )
118
118
end
119
119
Log .debug { " Install #{ exe_name } " }
120
120
source = File .join(install_path, exe_name)
You can’t perform that action at this time.
0 commit comments