Swap out panic for errors