Platform-independent error handling