From 1f18e740539aed751865ecff9d0f3cba44230e54 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 1 Oct 2020 11:49:53 +0200 Subject: Refactoring file structure, Added summary --- src/philo/error.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/philo/error.py (limited to 'src/philo/error.py') 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 +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# 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) -- cgit