lib/cpu/msr.rb in cpu-0.0.1 vs lib/cpu/msr.rb in cpu-0.0.2
- old
+ new
@@ -15,12 +15,15 @@
# Create a new wrapper for the msr kernel file associated with
# +processor_id+.
def initialize(processor_id)
self.class.available? or self.class.load_module
begin
- @io = IO.new IO.sysopen('/dev/cpu/%d/msr' % processor_id, 'rb')
+ name = '/dev/cpu/%d/msr' % processor_id
+ @io = IO.new IO.sysopen(name, 'rb')
rescue Errno::ENOENT
raise InvalidProcessorIdError, "'#{processor_id}' is not a valid processor_id on this machine"
+ rescue StandardError => e
+ raise NoSampleDataError, "could not read temperature from #{name}: #{e}"
end
end
# Returns the byte at +offset+ as an integer number.
def [](offset)