Return errors instead of panicking.