1#!/usr/bin/env python3
2
3"""Database model exceptions."""
4
5class NoSuchTable(Exception):
6 """Exception returned if client tries to create a TableInfo with an
7 unknown name.
8 """
9
10 def __init__(self, table_name):
11 super(NoSuchTable, self).__init__()
12 self.table_name = table_name
13
14 def __str__(self):
15 return 'No such table {table}'.format(table=self.table_name)
16
17
18class MultipleFields(Exception):
19 """Thrown if a find fields function is called without
20 the `multiple` switch, and multiple field names match.
21 """
22
23 def __init__(self, message):
24 super(MultipleFields, self).__init__()
25 self.message = message
26
27 def __str__(self):
28 return self.message
29
30
31class NoDataRange(Exception):
32 """Thrown if client code calls cal/raw_data_range on a floating point field."""
33
34 def __init__(self):
35 super(NoDataRange, self).__init__()
36
37 def __str__(self):
38 return "No data range can be given for this field"