scrapy/scrapy — Issue #49: exception handling
Author: warvariuc
Created: 2011-11-14 14:08:58+00:00
State: open

scrapy/spidermanager.py

def create(self, spider_name, **spider_kwargs):
try:
return self._spiders[spider_name](**spider_kwargs)
except KeyError:
raise KeyError("Spider not found: %s" % spider_name)

change to

def create(self, spider_name, **spider_kwargs):
try:
spcls = self._spiders[spider_name]
except KeyError:
raise KeyError("Spider not found: %s" % spider_name)
return spcls(**spider_kwargs)

i had a case when `spider.__init__` had a KeyError causing a misleading exception - 'spider not found'