Mercurial > libervia-backend
comparison libervia/frontends/bridge/bridge_frontend.py @ 4074:26b7ed2817da
refactoring: rename `sat_frontends` to `libervia.frontends`
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 02 Jun 2023 14:12:38 +0200 |
parents | sat_frontends/bridge/bridge_frontend.py@60d3861e5996 |
children |
comparison
equal
deleted
inserted
replaced
4073:7c5654c54fed | 4074:26b7ed2817da |
---|---|
1 #!/usr/bin/env python3 | |
2 | |
3 | |
4 # SAT communication bridge | |
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
20 | |
21 class BridgeException(Exception): | |
22 """An exception which has been raised from the backend and arrived to the frontend.""" | |
23 | |
24 def __init__(self, name, message="", condition=""): | |
25 """ | |
26 | |
27 @param name (str): full exception class name (with module) | |
28 @param message (str): error message | |
29 @param condition (str) : error condition | |
30 """ | |
31 super().__init__() | |
32 self.fullname = str(name) | |
33 self.message = str(message) | |
34 self.condition = str(condition) if condition else "" | |
35 self.module, __, self.classname = str(self.fullname).rpartition(".") | |
36 | |
37 def __str__(self): | |
38 return self.classname + (f": {self.message}" if self.message else "") | |
39 | |
40 def __eq__(self, other): | |
41 return self.classname == other |