- respond with 404 not found on /instance/{instID} endpoint
- this replaces a 500 internal error response which is misleading
Issue-ID: MULTICLOUD-1526
Change-Id: Ibbe49cbb3c1286546f7dd1d9c24834291b14d9be
Signed-off-by: Fiete Ostkamp <fiete.ostkamp@telekom.de>
}
if err != nil {
+ if err.Error() == "Get Instance: Error finding master table: mongo: no documents in result" {
+ http.Error(w, err.Error(), http.StatusNotFound)
+ return
+ }
log.Error("Error getting Instance", log.Fields{
"error": err,
"id": id,
},
},
{
- label: "Succesful get an Instance",
+ label: "Not found Instance",
+ input: "HaKpys8e",
+ expectedCode: http.StatusNotFound,
+ instClient: &mockInstanceClient{
+ err: pkgerrors.New("Get Instance: Error finding master table: mongo: no documents in result"),
+ },
+ },
+ {
+ label: "Successful get an Instance",
input: "HaKpys8e",
expectedCode: http.StatusOK,
expectedResponse: &app.InstanceResponse{