Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a9b753f

Browse files
committed
handle list not found
1 parent 7589b44 commit a9b753f

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

list/src/Controllers/ListController.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,28 @@ public async Task<IActionResult> Get(string? list = null)
5252
return Ok(result);
5353
}
5454

55-
// otherwise, if listId is provided, return all properties of list
56-
CrdList l = await zK8sList.generic.ReadNamespacedAsync<CrdList>(
57-
Globals.service.kubeconfig.Namespace, list);
55+
CrdList l = null;
56+
try
57+
{
58+
// otherwise, if listId is provided, return all properties of list
59+
l = await zK8sList.generic.ReadNamespacedAsync<CrdList>(
60+
Globals.service.kubeconfig.Namespace, list);
61+
}
62+
catch (k8s.Autorest.HttpOperationException ex)
63+
{
64+
/*
65+
Console.WriteLine("** one **");
66+
Console.WriteLine("StatusCode: " + ex.Response.StatusCode);
67+
Console.WriteLine(" Message: " + ex.Message);
68+
Console.WriteLine(" Data: " + ex.InnerException.Data);
69+
*/
70+
71+
if (ex.Response.StatusCode.Equals("Not Found"))
72+
{
73+
return StatusCode(StatusCodes.Status404NotFound);
74+
}
75+
}
76+
5877

5978
return Ok(l.Spec.list);
6079
}

0 commit comments

Comments
 (0)