Common error classes and utility functions