Don't use panics for error handling

This change makes the benchmarks run 10-20% faster.