Un-nest add_error method

The add_error method was nested inside a block but is needed outside of that block.