code: @Override
      public ErrorResponse deserialize(JsonElement element, Type type, JsonDeserializationContext context)
          throws JsonParseException
      {
          JsonObject obj = element.getAsJsonObject();
          JsonElement error = obj.get("error");
          JsonElement errors = obj.get("errors");
  
          if(errors != null)
              return gson.fromJson(element, ErrorDetails.class);
          else if(error != null && error.isJsonObject())
              return gson.fromJson(error, ErrorMessages.class);
          else
              return gson.fromJson(element, ErrorDetail.class);
      }
docs: Gson invokes this call-back method during deserialization when it encounters a field of the specified type.
  @param element The Json data being deserialized
  @param type The type of the Object to deserialize to
  @param context The JSON deserialization context
  @return The response errors