fix typo
[opensuse:osc.git] / osc / oscerr.py
1 # Copyright (C) 2008 Novell Inc.  All rights reserved.
2 # This program is free software; it may be used, copied, modified
3 # and distributed under the terms of the GNU General Public Licence,
4 # either version 2, or (at your option) any later version.
5
6
7
8 class OscBaseError(Exception):
9     def __init__(self, args=()):
10         Exception.__init__(self)
11         self.args = args
12     def __str__(self):
13         return ''.join(self.args)
14
15 class UserAbort(OscBaseError):
16     """Exception raised when the user requested abortion"""
17
18 class ConfigError(OscBaseError):
19     """Exception raised when there is an error in the config file"""
20     def __init__(self, msg, fname):
21         OscBaseError.__init__(self)
22         self.msg = msg
23         self.file = fname
24
25 class ConfigMissingApiurl(ConfigError):
26     """Exception raised when a apiurl does not exist in the config file"""
27     def __init__(self, msg, fname, url):
28         ConfigError.__init__(self, msg, fname)
29         self.url = url
30
31 class APIError(OscBaseError):
32     """Exception raised when there is an error in the output from the API"""
33     def __init__(self, msg):
34         OscBaseError.__init__(self)
35         self.msg = msg
36
37 class NoConfigfile(OscBaseError):
38     """Exception raised when osc's configfile cannot be found"""
39     def __init__(self, fname, msg):
40         OscBaseError.__init__(self)
41         self.file = fname
42         self.msg = msg
43
44 class RuntimeError(OscBaseError):
45     """Exception raised when there is a runtime error of an external tool"""
46     def __init__(self, msg, fname):
47         OscBaseError.__init__(self)
48         self.msg = msg
49         self.file = fname
50
51 class WrongArgs(OscBaseError):
52     """Exception raised by the cli for wrong arguments usage"""
53
54 class WrongOptions(OscBaseError):
55     """Exception raised by the cli for wrong option usage"""
56     #def __str__(self):
57     #    s = 'Sorry, wrong options.'
58     #    if self.args:
59     #        s += '\n' + self.args
60     #    return s
61
62 class NoWorkingCopy(OscBaseError):
63     """Exception raised when directory is neither a project dir nor a package dir"""
64
65 class WorkingCopyWrongVersion(OscBaseError):
66     """Exception raised when working copy's .osc/_osclib_version doesn't match"""
67
68 class WorkingCopyOutdated(OscBaseError):
69     """Exception raised when the working copy is outdated.
70     It takes a tuple with three arguments: path to wc,
71     revision that it has, revision that it should have.
72     """
73     def __str__(self):
74         return ('Working copy \'%s\' is out of date (rev %s vs rev %s).\n'
75                'Looks as if you need to update it first.' \
76                     % (self[0], self[1], self[2]))
77
78 class PackageError(OscBaseError):
79     """Base class for all Package related exceptions"""
80     def __init__(self, prj, pac):
81         OscBaseError.__init__(self)
82         self.prj = prj
83         self.pac = pac
84
85 class LinkExpandError(PackageError):
86     """Exception raised when source link expansion fails"""
87     def __init__(self, prj, pac, msg):
88         PackageError.__init__(self, prj, pac)
89         self.msg = msg
90
91 class OscIOError(OscBaseError):
92     def __init__(self, e, msg):
93         OscBaseError.__init__(self)
94         self.e = e
95         self.msg = msg
96
97 class SignalInterrupt(Exception):
98     """Exception raised on SIGTERM and SIGHUP."""
99
100 class PackageExists(PackageError):
101     """
102     Exception raised when a local object already exists
103     """
104     def __init__(self, prj, pac, msg):
105         PackageError.__init__(self, prj, pac)
106         self.msg = msg
107
108 class PackageMissing(PackageError):
109     """
110     Exception raised when a local object doesn't exist
111     """
112     def __init__(self, prj, pac, msg):
113         PackageError.__init__(self, prj, pac)
114         self.msg = msg
115
116 # vim: sw=4 et