From: Uwe Hermann Date: Fri, 25 Dec 2015 15:28:23 +0000 (+0100) Subject: usb_power_delivery: Raise SamplerateError instead of Exception. X-Git-Tag: libsigrokdecode-0.4.0~6 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=669f30f4b1035a8eb0a5350246a3bc50cf8b376d;p=libsigrokdecode.git usb_power_delivery: Raise SamplerateError instead of Exception. (for consistency with the other PDs) --- 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: