Package keyczar :: Module errors
[hide private]
[frames] | no frames]

Source Code for Module keyczar.errors

 1  #!/usr/bin/python2.4 
 2  # 
 3  # Copyright 2008 Google Inc. 
 4  # 
 5  # Licensed under the Apache License, Version 2.0 (the "License"); 
 6  # you may not use this file except in compliance with the License. 
 7  # You may obtain a copy of the License at 
 8  #  
 9  #      http://www.apache.org/licenses/LICENSE-2.0 
10  #  
11  # Unless required by applicable law or agreed to in writing, software 
12  # distributed under the License is distributed on an "AS IS" BASIS, 
13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14  # See the License for the specific language governing permissions and 
15  # limitations under the License. 
16   
17  """ 
18  Contains hierarchy of all possible exceptions thrown by Keyczar. 
19   
20  @author: arkajit.dey@gmail.com (Arkajit Dey) 
21  """ 
22   
23 -class KeyczarError(Exception):
24 """Indicates exceptions raised by a Keyczar class."""
25
26 -class BadVersionError(KeyczarError):
27 """Indicates a bad version number was received.""" 28
29 - def __init__(self, version):
30 KeyczarError.__init__(self, 31 "Received a bad version number: " + str(version))
32
33 -class Base64DecodingError(KeyczarError):
34 """Indicates an error while performing Base 64 decoding."""
35
36 -class InvalidSignatureError(KeyczarError):
37 """Indicates an invalid ciphertext signature.""" 38
39 - def __init__(self):
40 KeyczarError.__init__(self, "Invalid ciphertext signature")
41
42 -class KeyNotFoundError(KeyczarError):
43 """Indicates a key with a certain hash id was not found.""" 44
45 - def __init__(self, hash):
46 KeyczarError.__init__(self, 47 "Key with hash identifier %s not found." % hash)
48
49 -class ShortCiphertextError(KeyczarError):
50 """Indicates a ciphertext too short to be valid.""" 51
52 - def __init__(self, length):
53 KeyczarError.__init__(self, 54 "Input of length %s is too short to be valid ciphertext." % length)
55
56 -class ShortSignatureError(KeyczarError):
57 """Indicates a signature too short to be valid.""" 58
59 - def __init__(self, length):
60 KeyczarError.__init__(self, 61 "Input of length %s is too short to be valid signature." % length)
62
63 -class NoPrimaryKeyError(KeyNotFoundError):
64 """Indicates missing primary key.""" 65
66 - def __init__(self):
67 KeyczarError.__init__(self, "No primary key found")
68