Skip to content

Commit bb55d1c

Browse files
committed
Graceful error if serialport gem is needed.
1 parent 16de745 commit bb55d1c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tools/hardware/elm327_relay.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,20 @@
1010
####
1111
# This module requires a connected ELM327 or STN1100 is connected to
1212
# the machines serial. Sets up a basic RESTful web server to communicate
13-
# Requires MSF and the serialport gem
13+
#
14+
# Requires MSF and the serialport gem to be installed.
15+
# - `gem install serialport`
16+
# - or, if using rvm: `rvm gemset install serialport`
1417
####
1518

1619

1720
### Non-typical gem ###
18-
require 'serialport'
21+
begin
22+
require 'serialport'
23+
rescue LoadError => e
24+
gem = e.message.split.last
25+
abort "#{gem} is not installed. Please install with `gem install #{gem}' or, if using rvm, `rvm gemset install #{gem}' and try again."
26+
end
1927

2028
#
2129
# Load our MSF API

0 commit comments

Comments
 (0)