# Exceptions

## CanError

exception canlib.canlib.CanError

  Bases: `DllException`

  Base class for exceptions raised by the canlib class

  Looks up the error text in the canlib dll and presents it together with the error code and the wrapper function that triggered the exception.

## CanGeneralError

exception canlib.canlib.exceptions.CanGeneralError(status)

  Bases: `CanError`

  A canlib error that does not (yet) have its own Exception

  Warning

  Do not explicitly catch this error, instead catch `CanError`. Your error may at any point in the future get its own exception class, and so will no longer be of this type. The actual status code that raised any `CanError` can always be accessed through a `status` attribute.

## CanInvalidHandle

exception canlib.canlib.CanInvalidHandle

  Bases: `CanError`

  CANlib handle is invalid.

  Raised e.g. when trying to access a CAN channel via a closed channel handle.

  New in version 1.22.

  status = -10

## CanNoMsg

exception canlib.canlib.CanNoMsg

  Bases: `CanError`

  Raised when no matching message was available

  status = -2

## CanNotFound

exception canlib.canlib.CanNotFound

  Bases: `CanError`

  Specified device or channel not found

  There is no hardware available that matches the given search criteria. For example, you may have specified `Open.REQUIRE_EXTENDED` but there’s no controller capable of extended CAN. You may have specified a channel number that is out of the range for the hardware in question. You may have requested exclusive access to a channel, but the channel is already occupied.

  New in version 1.6.

  status = -3

## CanOutOfMemory

exception canlib.canlib.CanOutOfMemory

  Bases: `CanError`

  A memory allocation failed.

  Raised e.g. when trying to allocate an object buffer, when all available object buffers have already been allocated.

  New in version 1.22.

  status = -4

## CanScriptFail

exception canlib.canlib.CanScriptFail

  Bases: `CanError`

  Raised when a script call failed.

  This exception represents several different failures, for example:

  - Trying to load a corrupt file or not a .txe file

  - Trying to start a t script that has not been loaded

  - Trying to load a t script compiled with the wrong version of the t compiler

  - Trying to unload a t script that has not been stopped

  - Trying to use an envvar that does not exist

  status = -39

## CanTimeout

exception canlib.canlib.CanTimeout

  Bases: `CanError`

  Raised when a timeout occured

  Raised when an expected event did not happen within the expected time frame, see e.g. `canlib.Channel.writeWait()`.

  New in version 1.21.

  status = -7

## EnvvarException

exception canlib.canlib.EnvvarException

  Bases: `CanlibException`

  Base class for exceptions related to environment variables.

## EnvvarNameError

exception canlib.canlib.EnvvarNameError(envvar)

  Bases: `EnvvarException`

  Raised when the name of the environment variable is illegal.

## EnvvarValueError

exception canlib.canlib.EnvvarValueError(envvar, type_, value)

  Bases: `EnvvarException`

  Raised when the type of the value does not match the type of the environment variable.

## IoNoValidConfiguration

exception canlib.canlib.IoNoValidConfiguration

  Bases: `CanError`

  I/O pin configuration is invalid

  No I/O pins was found, or unknown I/O pins was discovered.

  New in version 1.8.

  status = -48

## IoPinConfigurationNotConfirmed

exception canlib.canlib.IoPinConfigurationNotConfirmed

  Bases: `CanError`

  I/O pin configuration is not confirmed

  Before accessing any I/O pin value, the device I/O pin configuration must be confirmed, using e.g. `Channel.io_confirm_config`.

  See also `iopin.Configuration`.

  New in version 1.8.

  status = -45

## TxeFileIsEncrypted

exception canlib.canlib.TxeFileIsEncrypted

  Bases: `CanlibException`

  Raised when trying to access `Txe.source` and the source and byte-code sections of the .txe binary have been encrypted.

  New in version 1.6.