Error handling framework