fix: throw on non-OK response in downloadMedia (Fixes JAVASCRIPT-REACT-B)
When the server returns a 4xx/5xx, downloadMedia was silently returning the error response body as a blob. decryptAttachment would then fail with a misleading 'Mismatched SHA-256 digest' instead of surfacing the real HTTP error. Now throws immediately so callers (useAsyncCallback) can show the correct error state. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -299,6 +299,7 @@ export const mxcUrlToHttp = (
|
||||
export const downloadMedia = async (src: string): Promise<Blob> => {
|
||||
// this request is authenticated by service worker
|
||||
const res = await fetch(src, { method: 'GET' });
|
||||
if (!res.ok) throw new Error(`Media download failed: ${res.status} ${res.statusText}`);
|
||||
const blob = await res.blob();
|
||||
return blob;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user