File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -277,6 +277,38 @@ def make(self, key):
277
277
raise SystemExit ('SIGTERM received' )
278
278
279
279
280
+ @schema
281
+ class DjExceptionNames (dj .Lookup ):
282
+ definition = """
283
+ dj_exception_name: char(64)
284
+ """
285
+ @property
286
+ def contents (self ):
287
+ ret = []
288
+ for e in dir (dj .errors ):
289
+ ea = getattr (dj .errors , e )
290
+ if callable (ea ):
291
+ try :
292
+ werks = (isinstance (ea , type (Exception ))
293
+ and isinstance (ea (), Exception ))
294
+ except TypeError as te :
295
+ pass
296
+ if werks :
297
+ ret .append ((e ,))
298
+ return ret
299
+
300
+
301
+ @schema
302
+ class ErrorClassTable (dj .Computed ):
303
+ definition = """
304
+ -> DjExceptionNames
305
+ """
306
+ def make (self , key ):
307
+ ename = key ['dj_exception_name' ]
308
+ raise getattr (dj .errors , ename )(ename )
309
+
310
+
311
+
280
312
@schema
281
313
class DecimalPrimaryKey (dj .Lookup ):
282
314
definition = """
Original file line number Diff line number Diff line change @@ -88,6 +88,18 @@ def test_sigterm():
88
88
assert_equals (error_message , 'SystemExit: SIGTERM received' )
89
89
schema .schema .jobs .delete ()
90
90
91
+
92
+ def test_suppress_dj_errors ():
93
+ ''' test_suppress_dj_errors: dj errors suppressable w/o native py blobs'''
94
+ schema .schema .jobs .delete ()
95
+ with dj .config (enable_python_native_blobs = False ):
96
+ schema .ErrorClassTable ().populate (
97
+ reserve_jobs = True , suppress_errors = True )
98
+
99
+ assert len (schema .DjExceptionNames ()) == len (schema .DjExceptionNames
100
+ & schema .schema .jobs )
101
+
102
+
91
103
def test_long_error_message ():
92
104
# clear out jobs table
93
105
schema .schema .jobs .delete ()
You can’t perform that action at this time.
0 commit comments