From 21cda9512f29947617da45822ab524b1f76f56c1 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Tue, 8 Jul 2014 21:32:32 +0200 Subject: Various PDs: Throw SamplerateError instead of Exception. Also, use the "if not self.samplerate" form, which catches both the case where self.samplerate is None, as well as the case where it is 0. --- decoders/ir_nec/pd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'decoders/ir_nec') diff --git a/decoders/ir_nec/pd.py b/decoders/ir_nec/pd.py index d9091be..ce2e9f2 100644 --- a/decoders/ir_nec/pd.py +++ b/decoders/ir_nec/pd.py @@ -21,6 +21,9 @@ import sigrokdecode as srd from .lists import * +class SamplerateError(Exception): + pass + class Decoder(srd.Decoder): api_version = 2 id = 'ir_nec' @@ -148,8 +151,8 @@ class Decoder(srd.Decoder): return ret == 0 def decode(self, ss, es, data): - if self.samplerate is None: - raise Exception("Cannot decode without samplerate.") + if not self.samplerate: + raise SamplerateError('Cannot decode without samplerate.') for (self.samplenum, pins) in data: self.ir = pins[0] -- cgit v1.2.3-70-g09d2