1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
|
.. GPIO Zero: a library for controlling the Raspberry Pi's GPIO pins
..
.. Copyright (c) 2016-2023 Dave Jones <dave@waveform.org.uk>
.. Copyright (c) 2019 Ben Nuttall <ben@bennuttall.com>
..
.. SPDX-License-Identifier: BSD-3-Clause
================
API - Exceptions
================
.. module:: gpiozero.exc
.. currentmodule:: gpiozero
The following exceptions are defined by GPIO Zero. Please note that multiple
inheritance is heavily used in the exception hierarchy to make testing for
exceptions easier. For example, to capture any exception generated by GPIO
Zero's code::
from gpiozero import *
led = PWMLED(17)
try:
led.value = 2
except GPIOZeroError:
print('A GPIO Zero error occurred')
Since all GPIO Zero's exceptions descend from :exc:`GPIOZeroError`, this will
work. However, certain specific errors have multiple parents. For example, in
the case that an out of range value is passed to :attr:`OutputDevice.value` you
would expect a :exc:`ValueError` to be raised. In fact, a
:exc:`OutputDeviceBadValue` error will be raised. However, note that this
descends from both :exc:`GPIOZeroError` (indirectly) and from :exc:`ValueError`
so you can still do the obvious::
from gpiozero import *
led = PWMLED(17)
try:
led.value = 2
except ValueError:
print('Bad value specified')
Errors
======
.. autoexception:: GPIOZeroError
:show-inheritance:
.. autoexception:: DeviceClosed
:show-inheritance:
.. autoexception:: BadEventHandler
:show-inheritance:
.. autoexception:: BadWaitTime
:show-inheritance:
.. autoexception:: BadQueueLen
:show-inheritance:
.. autoexception:: BadPinFactory
:show-inheritance:
.. autoexception:: ZombieThread
:show-inheritance:
.. autoexception:: CompositeDeviceError
:show-inheritance:
.. autoexception:: CompositeDeviceBadName
:show-inheritance:
.. autoexception:: CompositeDeviceBadOrder
:show-inheritance:
.. autoexception:: CompositeDeviceBadDevice
:show-inheritance:
.. autoexception:: EnergenieSocketMissing
:show-inheritance:
.. autoexception:: EnergenieBadSocket
:show-inheritance:
.. autoexception:: SPIError
:show-inheritance:
.. autoexception:: SPIBadArgs
:show-inheritance:
.. autoexception:: SPIBadChannel
:show-inheritance:
.. autoexception:: SPIFixedClockMode
:show-inheritance:
.. autoexception:: SPIInvalidClockMode
:show-inheritance:
.. autoexception:: SPIFixedBitOrder
:show-inheritance:
.. autoexception:: SPIFixedSelect
:show-inheritance:
.. autoexception:: SPIFixedWordSize
:show-inheritance:
.. autoexception:: SPIInvalidWordSize
:show-inheritance:
.. autoexception:: GPIODeviceError
:show-inheritance:
.. autoexception:: GPIODeviceClosed
:show-inheritance:
.. autoexception:: GPIOPinInUse
:show-inheritance:
.. autoexception:: GPIOPinMissing
:show-inheritance:
.. autoexception:: InputDeviceError
:show-inheritance:
.. autoexception:: OutputDeviceError
:show-inheritance:
.. autoexception:: OutputDeviceBadValue
:show-inheritance:
.. autoexception:: PinError
:show-inheritance:
.. autoexception:: PinInvalidFunction
:show-inheritance:
.. autoexception:: PinInvalidState
:show-inheritance:
.. autoexception:: PinInvalidPull
:show-inheritance:
.. autoexception:: PinInvalidEdges
:show-inheritance:
.. autoexception:: PinInvalidBounce
:show-inheritance:
.. autoexception:: PinSetInput
:show-inheritance:
.. autoexception:: PinFixedPull
:show-inheritance:
.. autoexception:: PinEdgeDetectUnsupported
:show-inheritance:
.. autoexception:: PinUnsupported
:show-inheritance:
.. autoexception:: PinSPIUnsupported
:show-inheritance:
.. autoexception:: PinPWMError
:show-inheritance:
.. autoexception:: PinPWMUnsupported
:show-inheritance:
.. autoexception:: PinPWMFixedValue
:show-inheritance:
.. autoexception:: PinUnknownPi
:show-inheritance:
.. autoexception:: PinMultiplePins
:show-inheritance:
.. autoexception:: PinNoPins
:show-inheritance:
.. autoexception:: PinInvalidPin
:show-inheritance:
Warnings
========
.. autoexception:: GPIOZeroWarning
:show-inheritance:
.. autoexception:: DistanceSensorNoEcho
:show-inheritance:
.. autoexception:: SPIWarning
:show-inheritance:
.. autoexception:: SPISoftwareFallback
:show-inheritance:
.. autoexception:: PinWarning
:show-inheritance:
.. autoexception:: PinFactoryFallback
:show-inheritance:
.. autoexception:: PinNonPhysical
:show-inheritance:
.. autoexception:: ThresholdOutOfRange
:show-inheritance:
.. autoexception:: CallbackSetToNone
:show-inheritance:
|