error handling for sending improper dictionary to JSON format