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.
8 class OscBaseError(Exception):
9 def __init__(self, args=()):
10 Exception.__init__(self)
13 return ''.join(self.args)
15 class UserAbort(OscBaseError):
16 """Exception raised when the user requested abortion"""
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)
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)
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)
37 class NoConfigfile(OscBaseError):
38 """Exception raised when osc's configfile cannot be found"""
39 def __init__(self, fname, msg):
40 OscBaseError.__init__(self)
44 class ExtRuntimeError(OscBaseError):
45 """Exception raised when there is a runtime error of an external tool"""
46 def __init__(self, msg, fname):
47 OscBaseError.__init__(self)
51 class WrongArgs(OscBaseError):
52 """Exception raised by the cli for wrong arguments usage"""
54 class WrongOptions(OscBaseError):
55 """Exception raised by the cli for wrong option usage"""
57 # s = 'Sorry, wrong options.'
59 # s += '\n' + self.args
62 class NoWorkingCopy(OscBaseError):
63 """Exception raised when directory is neither a project dir nor a package dir"""
65 class WorkingCopyWrongVersion(OscBaseError):
66 """Exception raised when working copy's .osc/_osclib_version doesn't match"""
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.
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]))
78 class PackageError(OscBaseError):
79 """Base class for all Package related exceptions"""
80 def __init__(self, prj, pac):
81 OscBaseError.__init__(self)
85 class WorkingCopyInconsistent(PackageError):
86 """Exception raised when the working copy is in an inconsistent state"""
87 def __init__(self, prj, pac, dirty_files, msg):
88 PackageError.__init__(self, prj, pac)
89 self.dirty_files = dirty_files
92 class LinkExpandError(PackageError):
93 """Exception raised when source link expansion fails"""
94 def __init__(self, prj, pac, msg):
95 PackageError.__init__(self, prj, pac)
98 class OscIOError(OscBaseError):
99 def __init__(self, e, msg):
100 OscBaseError.__init__(self)
104 class SignalInterrupt(Exception):
105 """Exception raised on SIGTERM and SIGHUP."""
107 class PackageExists(PackageError):
109 Exception raised when a local object already exists
111 def __init__(self, prj, pac, msg):
112 PackageError.__init__(self, prj, pac)
115 class PackageMissing(PackageError):
117 Exception raised when a local object doesn't exist
119 def __init__(self, prj, pac, msg):
120 PackageError.__init__(self, prj, pac)
123 class PackageFileConflict(PackageError):
125 Exception raised when there's a file conflict.
126 Conflict doesn't mean an unsuccessfull merge in this context.
128 def __init__(self, prj, pac, file, msg):
129 PackageError.__init__(self, prj, pac)
133 class PackageInternalError(PackageError):
134 def __init__(self, prj, pac, msg):
135 PackageError.__init__(self, prj, pac)