#NEWLINE# def handle_spider_error( self , _failure , request , response , spider ) : #NEWLINE# #INDENT# exc = _failure . value #NEWLINE# if isinstance ( exc , CloseSpider ) : #NEWLINE# #INDENT# self . crawler . engine . close_spider ( spider , ( exc . reason or 'cancelled' ) ) #NEWLINE# return #NEWLINE# #UNINDENT# logger . error ( 'Spider error processing %(request)s (referer: %(referer)s)' , { #NEWLINE# #INDENT# 'request' : request , #NEWLINE# 'referer' : referer_str ( request ) , #NEWLINE# #UNINDENT# } , exc_info = failure_to_exc_info ( _failure ) , extra = { #NEWLINE# #INDENT# 'spider' : spider , #NEWLINE# #UNINDENT# } ) #NEWLINE# self . signals . send_catch_log ( signal = signals . spider_error , failure = _failure , response = self , spider = spider ) #NEWLINE# self . crawler . stats . inc_value ( ( 'spider_exceptions/%s' % _failure . value . __class__ . __name__ ) , spider = spider )