Coverage for Exceptions.py: 63%

51 statements  

« prev     ^ index     » next       coverage.py v7.6.7, created at 2024-11-18 00:10 +0000

1#!/usr/bin/env python 

2# -*- coding: utf-8 -*- 

3 

4# Copyright 2009-2011 Matt Turnbull 

5# This program is free software: you can redistribute it and/or modify 

6# it under the terms of the GNU Affero General Public License as published by 

7# the Free Software Foundation, version 3 of the License. 

8# 

9# This program is distributed in the hope that it will be useful, 

10# but WITHOUT ANY WARRANTY; without even the implied warranty of 

11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

12# GNU General Public License for more details. 

13# 

14# You should have received a copy of the GNU Affero General Public License 

15# along with this program. If not, see <http://www.gnu.org/licenses/>. 

16# In the "official" distribution you can find the license in agpl-3.0.txt. 

17 

18 

19class FpdbError(Exception): 

20 def __init__(self, value): 

21 self.value = value 

22 

23 def __str__(self): 

24 return repr(self.value) 

25 

26 

27class FpdbParseError(FpdbError): 

28 def __init__(self, value="", hid=""): 

29 self.value = value 

30 self.hid = hid 

31 

32 def __str__(self): 

33 if self.hid: 

34 return repr("HID:" + self.hid + ", " + self.value) 

35 else: 

36 return repr(self.value) 

37 

38 

39class FpdbDatabaseError(FpdbError): 

40 pass 

41 

42 

43class FpdbMySQLError(FpdbDatabaseError): 

44 pass 

45 

46 

47class FpdbMySQLAccessDenied(FpdbDatabaseError): 

48 def __init__(self, value="", errmsg=""): 

49 self.value = value 

50 self.errmsg = errmsg 

51 

52 def __str__(self): 

53 return repr(self.value + " " + self.errmsg) 

54 

55 

56class FpdbMySQLNoDatabase(FpdbDatabaseError): 

57 def __init__(self, value="", errmsg=""): 

58 self.value = value 

59 self.errmsg = errmsg 

60 

61 def __str__(self): 

62 return repr(self.value + " " + self.errmsg) 

63 

64 

65class FpdbPostgresqlAccessDenied(FpdbDatabaseError): 

66 def __init__(self, value="", errmsg=""): 

67 self.value = value 

68 self.errmsg = errmsg 

69 

70 def __str__(self): 

71 return repr(self.value + " " + self.errmsg) 

72 

73 

74class FpdbPostgresqlNoDatabase(FpdbDatabaseError): 

75 def __init__(self, value="", errmsg=""): 

76 self.value = value 

77 self.errmsg = errmsg 

78 

79 def __str__(self): 

80 return repr(self.value + " " + self.errmsg) 

81 

82 

83class FpdbHandError(FpdbError): 

84 pass 

85 

86 

87class FpdbHandDuplicate(FpdbHandError): 

88 pass 

89 

90 

91class FpdbHandPartial(FpdbParseError): 

92 pass 

93 

94 

95class FpdbHandSkipped(FpdbParseError): 

96 pass 

97 

98 

99class FpdbEndOfFile(FpdbHandError): 

100 pass