Skip to content

Commit 2141ccd

Browse files
committed
error handle
1 parent 7139df0 commit 2141ccd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/system_command_helper.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ def sys(cmd)
99
end
1010
unless @no_exec
1111
result = system cmd
12-
if result != 0 && respond_to?(:sys_error, true)
13-
sys_error(cmd)
12+
if result != 0 && @on_error
13+
@on_error.call(cmd)
1414
end
1515
result
1616
end
@@ -24,4 +24,8 @@ def cap(cmd)
2424
`#{cmd}`
2525
end
2626
end
27+
28+
def on_error(&block)
29+
@on_error = block
30+
end
2731
end

0 commit comments

Comments
 (0)