You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Exceptions.md
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,3 +33,60 @@ Cosmos DB SDK on any IO failure will attempt to retry the failed operation if re
33
33
## Common error status codes and troubleshooting guide <aid="error-codes"></a>
34
34
35
35
To see a list of common error code and issues please see [.NET SDK troubleshooting guide](https://docs.microsoft.com/azure/cosmos-db/troubleshoot-dot-net-sdk)
36
+
37
+
### Disambiguating 404 (Not Found) errors using SubStatusCode <aid="substatus-codes"></a>
38
+
39
+
When you receive a 404 (Not Found) status code from Cosmos DB, it can indicate two different scenarios:
40
+
1.**Item not found**: The requested item doesn't exist in the container
41
+
2.**Owner resource not found**: The parent resource (container or database) doesn't exist
42
+
43
+
To distinguish between these cases, check the `SubStatusCode` property:
44
+
45
+
-**SubStatusCode 0**: Regular item not found (the item doesn't exist in an existing container)
46
+
-**SubStatusCode 1003**: Owner resource not found (the container or database doesn't exist)
47
+
48
+
#### Example with Typed APIs (throws CosmosException):
Console.WriteLine("Owner resource (container/database) not found");
83
+
}
84
+
else
85
+
{
86
+
// The item doesn't exist in an existing container
87
+
Console.WriteLine("Item not found");
88
+
}
89
+
}
90
+
```
91
+
92
+
This distinction is particularly useful when implementing retry logic or error handling strategies, as you may want to handle these scenarios differently (e.g., creating the container if it doesn't exist vs. handling a missing item).
0 commit comments