xref: /dpdk/dts/framework/exception.py (revision 09442498ef736d0a96632cf8b8c15d8ca78a6468)
1# SPDX-License-Identifier: BSD-3-Clause
2# Copyright(c) 2010-2014 Intel Corporation
3# Copyright(c) 2022 PANTHEON.tech s.r.o.
4# Copyright(c) 2022 University of New Hampshire
5
6"""
7User-defined exceptions used across the framework.
8"""
9
10
11class SSHTimeoutError(Exception):
12    """
13    Command execution timeout.
14    """
15
16    command: str
17    output: str
18
19    def __init__(self, command: str, output: str):
20        self.command = command
21        self.output = output
22
23    def __str__(self) -> str:
24        return f"TIMEOUT on {self.command}"
25
26    def get_output(self) -> str:
27        return self.output
28
29
30class SSHConnectionError(Exception):
31    """
32    SSH connection error.
33    """
34
35    host: str
36
37    def __init__(self, host: str):
38        self.host = host
39
40    def __str__(self) -> str:
41        return f"Error trying to connect with {self.host}"
42
43
44class SSHSessionDeadError(Exception):
45    """
46    SSH session is not alive.
47    It can no longer be used.
48    """
49
50    host: str
51
52    def __init__(self, host: str):
53        self.host = host
54
55    def __str__(self) -> str:
56        return f"SSH session with {self.host} has died"
57