Better error message for non-dict action response.
Handle exceptions when serializing json.