@Test
public void throwsExceptionWhenError() throws Exception {

    Request request = new Request.Builder()
            .url(URL).build();
    MediaType appJson = MediaType.parse("application/json");
    Response response = new Response.Builder()
            .code(401)
            .protocol(Protocol.HTTP_1_1)
            .request(request)
            .body(ResponseBody.create(appJson, getSampleBodyStringForErrorCode(1000)))
            .build();
    when(chain.proceed(any(Request.class))).thenReturn(response);
    try {
        interceptor.intercept(chain);
        fail("did not throw exception");
    } catch(TapglueError e) {
        assertThat(e.getCode(), equalTo(1000));
    }
}