Error handling for cupcake. Fixes #52