Exceptions
airvpn.exceptions
Hierarchy
AirVPNException
├── APIKeyRequired
├── InvalidService
├── LoginError
├── APIError
├── InvalidMethod
├── RateLimited
├── InvalidPort
├── ValidationError
├── DeviceException
│ ├── DeviceOperationError
│ └── DeviceValidationError
├── GeneratorException
│ └── GeneratorResponseError
└── ClientException
├── RCParseError
├── RSAError
├── AESEncryptionError
└── AESDecryptionError
Unless you need to distinguish a specific failure, catching
AirVPNException will handle every exception raised by the library.
Catch one of the intermediate base classes (DeviceException,
GeneratorException, or ClientException) to handle errors from a
particular component.
AESDecryptionError
Bases: ClientException
Raised when AES decryption fails.
AESEncryptionError
Bases: ClientException
Raised when AES encryption fails.
APIError
Bases: AirVPNException
Raised when the service request reports an error
APIKeyRequired
Bases: AirVPNException
Raised when a service is accessed without a configured API key.
Some AirVPN endpoints are user-specific and require an API key to
be set on the session before use (see services marked
__KEY_NEEDED__ = True). This is raised before any request is
made, as soon as a call to such a service is attempted without one.
AirVPNException
Bases: Exception
Base exception for all errors raised by the AirVPN API.
Catch this to handle any AirVPN-related failure without
distinguishing the cause; prefer the more specific subclasses
below when you need to branch on what went wrong. This includes
the exceptions raised directly by the main AirVPN class, as well
as the DeviceException and GeneratorException hierarchies
raised by the Devices manager and config Generator, both of which
subclass this exception.
ClientException
Bases: AirVPNException
Base exception for all errors raised by the client.
Subclasses AirVPNException. Catch this to handle any
client-related failure without distinguishing the cause; prefer
the more specific subclasses below when you need to branch on what
went wrong, or catch AirVPNException to handle any error raised
by the library as a whole.
DeviceException
Bases: AirVPNException
Base exception for all errors raised by the Devices manager.
Subclasses AirVPNException. Catch this to handle any
device-related failure without distinguishing the cause; prefer
the more specific subclasses below when you need to branch on what
went wrong, or catch AirVPNException to handle any error raised
by the library as a whole.
DeviceOperationError
Bases: DeviceException
Raised when a multi-step device operation doesn't complete as expected.
For example, get(..., create=True) creating a device but
receiving no ID back, or a subsequent rename not reporting success.
The individual API calls didn't necessarily report an error, but
the overall operation couldn't be completed.
DeviceValidationError
Bases: DeviceException
Raised when arguments passed to a Devices method are invalid, prior to any request being made.
For example, calling modify() without either a name or a
description to change.
GeneratorException
Bases: AirVPNException
Base exception for all errors raised by the config Generator.
Subclasses AirVPNException. Catch this to handle any
Generator-related failure without distinguishing the cause; prefer
the more specific subclasses below when you need to branch on what
went wrong, or catch AirVPNException to handle any error raised
by the library as a whole.
GeneratorResponseError
Bases: GeneratorException
Raised when the generator API's response doesn't match the expected shape.
For example, a JSON response that's missing the options field
create relies on to build a ConfigList. This indicates
an unexpected/malformed response rather than an error the API
deliberately reported, and may signal an API change worth
investigating.
InvalidAPIKey
Bases: AirVPNException
Raised when the API key specified doesn't exist
InvalidMethod
Bases: AirVPNException
Raised when an invalid method type is requested.
InvalidPort
Bases: AirVPNException
Raised when the port requested isn't available.
InvalidService
Bases: AirVPNException
Raised when an unrecognized or unsupported service is requested.
For example, looking up a service by name that doesn't correspond to any of AirVPN's known API services/endpoints.
LoginError
Bases: AirVPNException
Raised when authentication fails.
RCParseError
Bases: ClientException
Raised when an error with rc parsing happens.
RSAError
Bases: ClientException
Raised when RSA fails to encrypt key and iv.
RateLimited
Bases: AirVPNException
Raised when the rate limit of min(rate_window_minutes, 10) * AirSession.REQUESTS_PER_MIN is hit.
This is based off of the documentation in the FAQ (https://airvpn.org/faq/api/), which states you can only make 600 requests every 10 minutes or you will be IP banned.
ValidationError
Bases: AirVPNException
Raised when a validation check fails.