From 669f30f4b1035a8eb0a5350246a3bc50cf8b376d Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Fri, 25 Dec 2015 16:28:23 +0100 Subject: usb_power_delivery: Raise SamplerateError instead of Exception. (for consistency with the other PDs) --- decoders/usb_power_delivery/pd.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'decoders') diff --git a/decoders/usb_power_delivery/pd.py b/decoders/usb_power_delivery/pd.py index da73661..ad28d97 100644 --- a/decoders/usb_power_delivery/pd.py +++ b/decoders/usb_power_delivery/pd.py @@ -178,6 +178,9 @@ VDM_CMDS = { } VDM_ACK = ['REQ', 'ACK', 'NAK', 'BSY'] +class SamplerateError(Exception): + pass + class Decoder(srd.Decoder): api_version = 2 id = 'usb_power_delivery' @@ -469,7 +472,7 @@ class Decoder(srd.Decoder): def us2samples(self, us): if not self.samplerate: - raise Exception('Need the samplerate.') + raise SamplerateError('Need the samplerate.') return int(us * self.samplerate / 1000000) def decode_packet(self): @@ -528,7 +531,7 @@ class Decoder(srd.Decoder): def decode(self, ss, es, data): if not self.samplerate: - raise Exception('Cannot decode without samplerate.') + raise SamplerateError('Cannot decode without samplerate.') for (self.samplenum, pins) in data: # find edges ... if self.oldpins == pins: -- cgit v1.2.3-70-g09d2