I would define the raise_error method globally, once.