diff --git a/pkg/api/api_bucket_handlers.go b/pkg/api/api_bucket_handlers.go index a81874181..274519bff 100644 --- a/pkg/api/api_bucket_handlers.go +++ b/pkg/api/api_bucket_handlers.go @@ -105,14 +105,9 @@ func (server *minioAPI) listBucketsHandler(w http.ResponseWriter, req *http.Requ encodedResponse := encodeResponse(response, acceptsContentType) w.Write(encodedResponse) } - case drivers.BackendCorrupted: - { - log.Error.Println(err) - writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) - } default: { - log.Error.Println(err) + log.Error.Println(iodine.New(err, nil)) writeErrorResponse(w, req, InternalError, acceptsContentType, req.URL.Path) } } diff --git a/pkg/api/api_test.go b/pkg/api/api_test.go index 2a04f9517..33e8cd2b3 100644 --- a/pkg/api/api_test.go +++ b/pkg/api/api_test.go @@ -894,19 +894,9 @@ func (s *MySuite) TestPartialContent(c *C) { } func (s *MySuite) TestListObjectsHandlerErrors(c *C) { - switch driver := s.Driver.(type) { - case *mocks.Driver: - { - driver.AssertExpectations(c) - } - default: - { - // We mock failures here to test - return - } - } - driver := s.Driver - typedDriver := s.MockDriver + driver := startMockDriver() + typedDriver := driver + defer driver.AssertExpectations(c) httpHandler := api.HTTPHandler("", driver) testServer := httptest.NewServer(httpHandler) @@ -942,6 +932,24 @@ func (s *MySuite) TestListObjectsHandlerErrors(c *C) { verifyError(c, response, "InternalError", "We encountered an internal error, please try again.", http.StatusInternalServerError) } +func (s *MySuite) TestListBucketsErrors(c *C) { + driver := startMockDriver() + typedDriver := driver + defer driver.AssertExpectations(c) + + httpHandler := api.HTTPHandler("", driver) + testServer := httptest.NewServer(httpHandler) + defer testServer.Close() + client := http.Client{} + + typedDriver.On("ListObjects", "foo", mock.Anything).Return(make([]drivers.ObjectMetadata, 0), drivers.BucketResourcesMetadata{}, drivers.BackendCorrupted{}).Once() + request, err := http.NewRequest("GET", testServer.URL+"/foo", bytes.NewBufferString("")) + c.Assert(err, IsNil) + response, err := client.Do(request) + c.Assert(err, IsNil) + verifyError(c, response, "InternalError", "We encountered an internal error, please try again.", http.StatusInternalServerError) +} + func verifyError(c *C, response *http.Response, code, description string, statusCode int) { data, err := ioutil.ReadAll(response.Body) c.Assert(err, IsNil)