~aleteoryx/muditaos

ref: c81e7934f6b6fd85ab4ce7a0311a4593aa700786 muditaos/test/harness/interface/error.py -rw-r--r-- 646 bytes
c81e7934 — Bartosz Cichocki [EGD-4437] added version check script (#1086) 5 years ago
                                                                                
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
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

from enum import IntEnum


class Error(IntEnum):
    PORT_NOT_FOUND = 1,
    PORT_FILE_NOT_FOUND = 2,
    TEST_FAILED = 3,
    VERSION_MISMATCH = 4,
    OTHER_ERROR = 5


class TestError(Exception):

    def __init__(self, error_code: Error):
        self.error_code = error_code
        self.message = f"Test failed with error code: {error_code.name}"
        super().__init__(self.message)

    def __str__(self):
        return self.message

    def get_error_code(self):
        return int(self.error_code)