diff options
| author | Charles Cabergs <me@cacharle.xyz> | 2020-10-01 11:49:53 +0200 |
|---|---|---|
| committer | Charles Cabergs <me@cacharle.xyz> | 2020-10-01 11:49:53 +0200 |
| commit | 1f18e740539aed751865ecff9d0f3cba44230e54 (patch) | |
| tree | e23254751cc5a3be551233efb979a00571f40dc6 /src/philo/error.py | |
| parent | 763f02a8b1e69c0e26a088824981d23ba1e5386d (diff) | |
| download | philosophers_test-1f18e740539aed751865ecff9d0f3cba44230e54.tar.gz philosophers_test-1f18e740539aed751865ecff9d0f3cba44230e54.tar.bz2 philosophers_test-1f18e740539aed751865ecff9d0f3cba44230e54.zip | |
Refactoring file structure, Added summary
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) |
