mirror of
https://github.com/DeBrosOfficial/network-ts-sdk.git
synced 2025-12-11 01:58:49 +00:00
Enhance HttpClient error handling for expected 404 responses
- Added logic to identify and handle expected 404 errors for conversation participants without logging them as errors. - Updated comments to clarify the expected behavior for cache misses and non-participant status, improving code readability.
This commit is contained in:
parent
2cdb78ee1d
commit
06d58fe85b
@ -179,8 +179,31 @@ export class HttpClient {
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
if (isCacheGetNotFound || isBlockedUsersNotFound) {
|
// "Not found" (404) for conversation_participants is expected behavior - don't log as error
|
||||||
// Log cache miss or non-blocked status as debug/info, not error
|
// This happens when checking if a user is a participant (e.g., on first group join)
|
||||||
|
const isConversationParticipantNotFound =
|
||||||
|
path === "/v1/rqlite/find-one" &&
|
||||||
|
error instanceof SDKError &&
|
||||||
|
error.httpStatus === 404 &&
|
||||||
|
options.body &&
|
||||||
|
(() => {
|
||||||
|
try {
|
||||||
|
const body =
|
||||||
|
typeof options.body === "string"
|
||||||
|
? JSON.parse(options.body)
|
||||||
|
: options.body;
|
||||||
|
return body.table === "conversation_participants";
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (
|
||||||
|
isCacheGetNotFound ||
|
||||||
|
isBlockedUsersNotFound ||
|
||||||
|
isConversationParticipantNotFound
|
||||||
|
) {
|
||||||
|
// Log cache miss, non-blocked status, or non-participant status as debug/info, not error
|
||||||
// These are expected behaviors
|
// These are expected behaviors
|
||||||
} else {
|
} else {
|
||||||
console.error(
|
console.error(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user