Skip to content

Conversation

@dtdesign
Copy link
Member

@dtdesign dtdesign commented Aug 13, 2025

A lot of RPC endpoints have turned out to be infallible, which means that they do not return an error under normal circumstances. Any error is the result of either an unexpected server error or a bug in the client code that makes the call thus all instances where such a request fails it should fail hard and loud.

This PR introduces a new alert dialog that is raised whenever such an unexpected error case is hit. This is strictly meant to be a fall-back case and should not be relied on as an expected behavior.

Example of the code before and after:

export async function closeReport(queueId: number, markAsJustified: boolean): Promise<ApiResult<[]>> {
try {
await prepareRequest(`${window.WSC_RPC_API_URL}core/moderation-queues/${queueId}/close`)
.post({
markAsJustified,
})
.fetchAsJson();
} catch (e) {
return apiResultFromError(e);
}
return apiResultFromValue([]);
}

After the PR:

export async function closeReport(queueId: number, markAsJustified: boolean): Promise<[]> {
return fromInfallibleApiRequest(() => {
return prepareRequest(`${window.WSC_RPC_API_URL}core/moderation-queues/${queueId}/close`)
.post({
markAsJustified,
})
.fetchAsJson();
});
}

@dtdesign dtdesign merged commit e992eaa into 6.2 Aug 13, 2025
9 checks passed
@dtdesign dtdesign deleted the 62-infallible-api-request branch August 13, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants