diff options
Diffstat (limited to 'src/philo/error.py')
| -rw-r--r-- | src/philo/error.py | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/philo/error.py b/src/philo/error.py new file mode 100644 index 0000000..51c3f7b --- /dev/null +++ b/src/philo/error.py @@ -0,0 +1,62 @@ +# ############################################################################ # +# # +# ::: :::::::: # +# error.py :+: :+: :+: # +# +:+ +:+ +:+ # +# By: cacharle <me@cacharle.xyz> +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2020/09/29 09:09:31 by cacharle #+# #+# # +# Updated: 2020/09/29 11:14:08 by cacharle ### ########.fr # +# # +# ############################################################################ # + +class Philo(Exception): + pass + + +class ShouldFail(Philo): + def __init__(self, msg: str): + self._msg = msg + Philo.__init__(self) + + @property + def full_summary(self): + return self.summary + + @property + def summary(self): + return "Should fail: {}".format(self._msg) + + +class Format(Philo): + def __init__(self, line: str, msg: str): + self._line = line + self._msg = msg + Philo.__init__(self) + + @property + def full_summary(self): + return """FORMAT ERROR: {} +{} +""".format(self._msg, self._line) + + @property + def summary(self): + return "format: {} {}".format(self._line, self._msg) + + +class Log(Philo): + def __init__(self, logs: [str], msg: str): + self._logs = logs + self._msg = msg + Philo.__init__(self) + + @property + def full_summary(self): + return """LOG ERROR: {} +{} +""".format(self._msg, '\n'.join([str(l) for l in self._logs])) + + @property + def summary(self): + return "log: {}".format(self._msg) |
