error handling best practices

it's not exactly the same, and I try to avoid pattern matching whenever possible