reduce side effects in _record_script_error

Method signature makes more sense now and removes some duplicate code.
add more specific checks for usage example loading

now differentiates between a KeyError and AttributeError

based on feedback from @wasade