better error handling for pickles