raise error in correct place