Implement and use custom error classes