#NEWLINE# @ contextlib . contextmanager #NEWLINE# def _backend_error_handling( backend , reraise = None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( yield ) #NEWLINE# #UNINDENT# except exceptions . ValidationError as e : #NEWLINE# #INDENT# logger . error ( '%s backend returned bad data: %s' , backend . actor_ref . actor_class . __name__ , e ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# if ( e and isinstance ( e , reraise ) ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# logger . exception ( '%s backend caused an exception.' , backend . actor_ref . actor_class . __name__ )