@SuppressWarnings({"unchecked", "ConstantConditions"})
  public <T extends RecordTemplate> T getErrorDetailsRecord()
  {
    if (_errorResponse.hasErrorDetails() && _errorResponse.hasErrorDetailType())
    {
      String type = _errorResponse.getErrorDetailType();
      try
      {
        Class<?> typeClass = Class.forName(type);
        if (RecordTemplate.class.isAssignableFrom(typeClass))
        {
          Class<? extends RecordTemplate> recordType = typeClass.asSubclass(RecordTemplate.class);
          RecordDataSchema schema = (RecordDataSchema) DataTemplateUtil.getSchema(typeClass);
          return (T) DataTemplateUtil.wrap(_errorResponse.getErrorDetails().data(), schema, recordType);
        }
      }
      catch (ClassNotFoundException e)
      {
        return null;
      }
    }
    return null;
  }
@Test
  public void testGetErrorDetailsRecord()
  {
    RestLiResponseException restLiResponseException;

    // No error detail data
    restLiResponseException = new RestLiResponseException(new ErrorResponse()
        .setStatus(500));
    Assert.assertNull(restLiResponseException.getErrorDetailsRecord());

    // Error detail data without a specified type
    restLiResponseException = new RestLiResponseException(new ErrorResponse()
      .setStatus(500)
      .setErrorDetails(new ErrorDetails()));
    Assert.assertNull(restLiResponseException.getErrorDetailsRecord());

    // Error detail data with an invalid type
    restLiResponseException = new RestLiResponseException(new ErrorResponse()
        .setStatus(500)
        .setErrorDetails(new ErrorDetails())
        .setErrorDetailType("com.fake.stupid.forged.ClassName"));
    Assert.assertNull(restLiResponseException.getErrorDetailsRecord());

    // Error detail data with a specified type
    restLiResponseException = new RestLiResponseException(new ErrorResponse()
        .setStatus(500)
        .setErrorDetails(new ErrorDetails())
        .setErrorDetailType(EmptyRecord.class.getCanonicalName()));
    Assert.assertEquals(restLiResponseException.getErrorDetailsRecord().getClass(), EmptyRecord.class);
  }