blob: f6b83749b78c0468a050c3da8fe72d1e26b471ba [file] [log] [blame]
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Module for Local Agent related errors.
The error subclasses are intended to make it easier to distinguish between and
handle different types of error exceptions.
"""
DEFAULT_ERROR_CODE = 0
class CredentialsExpiredError(Exception):
"""Raised when the user's credentials (auth token) are expired"""
err_code = 1
class ServiceError(Exception):
"""Raised when a service error occurs"""
err_code = 2
class InvalidRPCError(Exception):
"""Raised when an invalid rpc command is given"""
err_code = 3
class DeviceNotConnectedError(Exception):
"""Raised when querying an unconnected device"""
err_code = 4
class HandlerNotFoundError(Exception):
"""Raised when no correct handler is found"""
err_code = 5
class HandlersCollisionError(Exception):
"""Raised when 2 registered handlers share the same method when they are instantiated"""
err_code = 6
class HandlerInvalidError(Exception):
"""Raised when the registered handler is not a subclass of BaseCommandHandler"""
err_code = 7
class DeviceNotOpenError(Exception):
"""Raised when accessing a device which is not open yet."""
err_code = 8
class InvalidTestSuiteSessionError(Exception):
"""Raised when encountering an invalid testsuite session."""
err_code = 9
class AmsClientError(Exception):
"""Base exception for any AmsClient exceptions."""
err_code = 10
class CredentialsError(AmsClientError):
"""Exception for invalid local agent credentials."""
err_code = 11
class ApiTimeoutError(AmsClientError):
"""Exception for AMS API timed out."""
err_code = 12
class ApiError(AmsClientError):
"""Exception for unexpected status code in API response."""
err_code = 13
class UnlinkedError(CredentialsExpiredError):
"""Raised when the local agent is unlinked from AMS."""
err_code = 14
class RpcTimeOutError(InvalidRPCError):
"""Raised when the RPC request handling times out."""
err_code = 15