title: Handling errors using retrofit
body: <p>I have a call to an API using retrofit to register a user, I want to handle the 401 error when the user enters a phone number or email that already exists or is of the wrong format.</p>
  
  <pre><code>                    Gson gson = new Gson();
                      Type type = new TypeToken&lt;ErrorResponse&gt;() {}.getType();
                      ErrorResponse errorResponse = gson.fromJson(response.errorBody().charStream(),type);
                     Log.d("err", errorResponse.getMessage().getPhone().get(0))
  </code></pre>
  
  <p>The above is my code which  only displays for a single entity like phone..How do i get error message for both the phone and email from the json response</p>
  
  <pre><code>{
  "status": false,
  "message": {
      "email": [
          "The email has already been taken."
      ],
      "phone_no": [
          "The phone no has already been taken."
      ]
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This is the Json response</p>
  
  <pre><code>public class ErrorResponse {
  @SerializedName("success")
  @Expose
  private Boolean success;
  @SerializedName("message")
  @Expose
  private Message message;
  
  
  
  public Boolean getSuccess() {
      return success;
  }
  
  public void setSuccess(Boolean success) {
      this.success = success;
  }
  
  public Message getMessage() {
      return message;
  }
  
  public void setMessage(Message message) {
      this.message = message;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Then the error response</p>