Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 445886fb

Přidáno uživatelem David Friesecký před téměř 4 roky(ů)

Re #8884 - Improved exceptions in repositories

Zobrazit rozdíly:

src/dao/private_key_repository.py
49 49
            self.cursor.execute(sql, values)
50 50
            last_id = self.cursor.lastrowid
51 51
            self.connection.commit()
52
        except IntegrityError:
53
            Logger.error(INTEGRITY_ERROR_MSG)
54
            raise DatabaseException(INTEGRITY_ERROR_MSG)
55
        except ProgrammingError:
56
            Logger.error(PROGRAMMING_ERROR_MSG)
57
            raise DatabaseException(PROGRAMMING_ERROR_MSG)
58
        except OperationalError:
59
            Logger.error(OPERATIONAL_ERROR_MSG)
60
            raise DatabaseException(OPERATIONAL_ERROR_MSG)
61
        except NotSupportedError:
62
            Logger.error(NOT_SUPPORTED_ERROR_MSG)
63
            raise DatabaseException(NOT_SUPPORTED_ERROR_MSG)
64
        except DatabaseError:
65
            Logger.error(DATABASE_ERROR_MSG)
66
            raise DatabaseException(DATABASE_ERROR_MSG)
67
        except Error:
68
            Logger.error(ERROR_MSG)
69
            raise DatabaseException(ERROR_MSG)
52

  
53
        except (IntegrityError, OperationalError, ProgrammingError, NotSupportedError, DatabaseError, Error) as e:
54
            Logger.error(str(e))
55
            raise DatabaseException(e)
70 56

  
71 57
        return last_id
72 58

  
......
92 78
            private_key: PrivateKey = PrivateKey(private_key_row[0],
93 79
                                                 private_key_row[1],
94 80
                                                 private_key_row[2])
95
        except IntegrityError:
96
            Logger.error(INTEGRITY_ERROR_MSG)
97
            raise DatabaseException(INTEGRITY_ERROR_MSG)
98
        except ProgrammingError:
99
            Logger.error(PROGRAMMING_ERROR_MSG)
100
            raise DatabaseException(PROGRAMMING_ERROR_MSG)
101
        except OperationalError:
102
            Logger.error(OPERATIONAL_ERROR_MSG)
103
            raise DatabaseException(OPERATIONAL_ERROR_MSG)
104
        except NotSupportedError:
105
            Logger.error(NOT_SUPPORTED_ERROR_MSG)
106
            raise DatabaseException(NOT_SUPPORTED_ERROR_MSG)
107
        except DatabaseError:
108
            Logger.error(DATABASE_ERROR_MSG)
109
            raise DatabaseException(DATABASE_ERROR_MSG)
110
        except Error:
111
            Logger.error(ERROR_MSG)
112
            raise DatabaseException(ERROR_MSG)
81

  
82
        except (IntegrityError, OperationalError, ProgrammingError, NotSupportedError, DatabaseError, Error) as e:
83
            Logger.error(str(e))
84
            raise DatabaseException(e)
113 85

  
114 86
        return private_key
115 87

  
......
171 143
                private_keys.append(PrivateKey(private_key_row[0],
172 144
                                               private_key_row[1],
173 145
                                               private_key_row[2]))
174
        except IntegrityError:
175
            Logger.error(INTEGRITY_ERROR_MSG)
176
            raise DatabaseException(INTEGRITY_ERROR_MSG)
177
        except ProgrammingError:
178
            Logger.error(PROGRAMMING_ERROR_MSG)
179
            raise DatabaseException(PROGRAMMING_ERROR_MSG)
180
        except OperationalError:
181
            Logger.error(OPERATIONAL_ERROR_MSG)
182
            raise DatabaseException(OPERATIONAL_ERROR_MSG)
183
        except NotSupportedError:
184
            Logger.error(NOT_SUPPORTED_ERROR_MSG)
185
            raise DatabaseException(NOT_SUPPORTED_ERROR_MSG)
186
        except DatabaseError:
187
            Logger.error(DATABASE_ERROR_MSG)
188
            raise DatabaseException(DATABASE_ERROR_MSG)
189
        except Error:
190
            Logger.error(ERROR_MSG)
191
            raise DatabaseException(ERROR_MSG)
146

  
147
        except (IntegrityError, OperationalError, ProgrammingError, NotSupportedError, DatabaseError, Error) as e:
148
            Logger.error(str(e))
149
            raise DatabaseException(e)
192 150

  
193 151
        return private_keys
194 152

  
......
212 170
                      private_key_id]
213 171
            self.cursor.execute(sql, values)
214 172
            self.connection.commit()
215
        except IntegrityError:
216
            Logger.error(INTEGRITY_ERROR_MSG)
217
            raise DatabaseException(INTEGRITY_ERROR_MSG)
218
        except ProgrammingError:
219
            Logger.error(PROGRAMMING_ERROR_MSG)
220
            raise DatabaseException(PROGRAMMING_ERROR_MSG)
221
        except OperationalError:
222
            Logger.error(OPERATIONAL_ERROR_MSG)
223
            raise DatabaseException(OPERATIONAL_ERROR_MSG)
224
        except NotSupportedError:
225
            Logger.error(NOT_SUPPORTED_ERROR_MSG)
226
            raise DatabaseException(NOT_SUPPORTED_ERROR_MSG)
227
        except DatabaseError:
228
            Logger.error(DATABASE_ERROR_MSG)
229
            raise DatabaseException(DATABASE_ERROR_MSG)
230
        except Error:
231
            Logger.error(ERROR_MSG)
232
            raise DatabaseException(ERROR_MSG)
173

  
174
        except (IntegrityError, OperationalError, ProgrammingError, NotSupportedError, DatabaseError, Error) as e:
175
            Logger.error(str(e))
176
            raise DatabaseException(e)
233 177

  
234 178
        return self.cursor.rowcount > 0
235 179

  
......
248 192
            values = [private_key_id]
249 193
            self.cursor.execute(sql, values)
250 194
            self.connection.commit()
251
        except IntegrityError:
252
            Logger.error(INTEGRITY_ERROR_MSG)
253
            raise DatabaseException(INTEGRITY_ERROR_MSG)
254
        except ProgrammingError:
255
            Logger.error(PROGRAMMING_ERROR_MSG)
256
            raise DatabaseException(PROGRAMMING_ERROR_MSG)
257
        except OperationalError:
258
            Logger.error(OPERATIONAL_ERROR_MSG)
259
            raise DatabaseException(OPERATIONAL_ERROR_MSG)
260
        except NotSupportedError:
261
            Logger.error(NOT_SUPPORTED_ERROR_MSG)
262
            raise DatabaseException(NOT_SUPPORTED_ERROR_MSG)
263
        except DatabaseError:
264
            Logger.error(DATABASE_ERROR_MSG)
265
            raise DatabaseException(DATABASE_ERROR_MSG)
266
        except Error:
267
            Logger.error(ERROR_MSG)
268
            raise DatabaseException(ERROR_MSG)
195

  
196
        except (IntegrityError, OperationalError, ProgrammingError, NotSupportedError, DatabaseError, Error) as e:
197
            Logger.error(str(e))
198
            raise DatabaseException(e)
269 199

  
270 200
        return self.cursor.rowcount > 0

Také k dispozici: Unified diff