Debian Codegraph @

nixio/exceptions/exceptions.py

raw symbols SCIP
1 # -*- coding: utf-8 -*-
2 # Copyright © 2016, German Neuroinformatics Node (G-Node)
3 #
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted under the terms of the BSD License. See
8 # LICENSE file in the root of the Project.
9
10
11 class DuplicateName(Exception):
12
13 def __init__(self, caller, *args, **kwargs):
14 self.message = ("Duplicate name - "
15 "names have to be unique for a given "
16 "entity type & parent. ({})").format(caller)
17 super(DuplicateName, self).__init__(self.message, *args, **kwargs)
18
19
20 class UninitializedEntity(Exception):
21
22 def __init__(self, *args, **kwargs):
23 self.message = "The Entity being accessed is uninitialized or empty."
24 super(UninitializedEntity, self).__init__(self.message,
25 *args, **kwargs)
26
27
28 class InvalidUnit(ValueError):
29
30 def __init__(self, what, where):
31 self.message = "InvalidUnit: {} evoked at: {}".format(what, where)
32 super(InvalidUnit, self).__init__(self.message)
33
34
35 class InvalidAttrType(TypeError):
36
37 def __init__(self, type_, value):
38 self.message = ("Attribute requires type {} but {} "
39 "was provided.".format(type_, type(value)))
40 super(InvalidAttrType, self).__init__(self.message)
41
42
43 class InvalidEntity(Exception):
44
45 def __init__(self, *args, **kwargs):
46 self.message = "Invalid entity found in HDF5 file."
47 super(InvalidEntity, self).__init__(self.message, *args, **kwargs)
48
49
50 class InvalidSlice(Exception):
51
52 def __init__(self, *args, **kwargs):
53 self.message = "Trying to access data with an invalid slice."
54 super(InvalidSlice, self).__init__(self.message, *args, **kwargs)
55
56
57 class OutOfBounds(IndexError):
58
59 def __init__(self, message, index=None):
60 self.message = message
61 if index is not None:
62 self.message += " [at index: {}]".format(index)
63 super(OutOfBounds, self).__init__(self.message)
64
65
66 class IncompatibleDimensions(ValueError):
67
68 def __init__(self, what, where):
69 self.message = "IncompatibleDimensions: {} evoked at: {})".format(
70 what, where
71 )
72 super(IncompatibleDimensions, self).__init__(self.message)
73
74
75 class InvalidFile(Exception):
76
77 def __init__(self):
78 self.message = "Invalid file - file is not a nix file."
79 super(InvalidFile, self).__init__(self.message)
80
81
82 class DuplicateColumnName(Exception):
83
84 def __init__(self):
85 self.message = "Column names for a DataFrame have to be unique."
86 super(DuplicateColumnName, self).__init__(self.message)
87
88
89 class UnsupportedLinkType(Exception):
90
91 def __init__(self, objtype, linktype):
92 self.message = "LinkType {} is not supported for {}".format(linktype, objtype)
93 super(UnsupportedLinkType, self).__init__(self.message)