Louis Verhaard | 7db7896 | 2020-05-25 15:05:26 +0200 | [diff] [blame^] | 1 | # Copyright (C) 2020 Arm Limited or its affiliates. All rights reserved. |
| 2 | # |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the License); you may |
| 6 | # not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # Description: |
| 17 | # Defines custom exceptions. |
| 18 | |
| 19 | |
| 20 | class VelaError(Exception): |
| 21 | """Base class for vela exceptions""" |
| 22 | |
| 23 | def __init__(self, data): |
| 24 | self.data = data |
| 25 | |
| 26 | def __str__(self): |
| 27 | return repr(self.data) |
| 28 | |
| 29 | |
| 30 | class InputFileError(VelaError): |
| 31 | """Raised when reading the input file results in errors""" |
| 32 | |
| 33 | def __init__(self, file_name, msg): |
| 34 | self.data = "Error reading {}: {}".format(file_name, msg) |
| 35 | |
| 36 | |
| 37 | class UnsupportedFeatureError(VelaError): |
| 38 | """Raised when the input file uses non-supported features that cannot be handled""" |
| 39 | |
| 40 | def __init__(self, data): |
| 41 | self.data = "The input file uses a feature that is currently not supported: {}".format(data) |
| 42 | |
| 43 | |
| 44 | class OptionError(VelaError): |
| 45 | """Raised when an incorrect command line option is used""" |
| 46 | |
| 47 | def __init__(self, option, option_value, msg): |
| 48 | self.data = "Incorrect argument: {} {}: {}".format(option, option_value, msg) |