/
exc.py
59 lines (36 loc) · 1.29 KB
/
exc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""Exceptions for tmuxp.
tmuxp.exc
~~~~~~~~~
"""
from __future__ import absolute_import, unicode_literals
from ._compat import implements_to_string
class TmuxpException(Exception):
"""Base Exception for Tmuxp Errors."""
class ConfigError(TmuxpException):
"""Error parsing tmuxp configuration dict."""
pass
class EmptyConfigException(ConfigError):
"""Configuration is empty."""
pass
class BeforeLoadScriptNotExists(OSError):
def __init__(self, *args, **kwargs):
super(BeforeLoadScriptNotExists, self).__init__(*args, **kwargs)
self.strerror = "before_script file '%s' doesn't exist." % self.strerror
@implements_to_string
class BeforeLoadScriptError(Exception):
"""Exception replacing :py:class:`subprocess.CalledProcessError` for
:meth:`tmuxp.util.run_before_script`.
"""
def __init__(self, returncode, cmd, output=None):
self.returncode = returncode
self.cmd = cmd
self.output = output
self.message = (
'before_script failed with returncode {returncode}.\n'
'command: {cmd}\n'
'Error output:\n'
'{output}'
).format(returncode=self.returncode, cmd=self.cmd, output=self.output)
def __str__(self):
return self.message