Skip to content

Commit d92b69c

Browse files
Fix blossom upload error
We weren't handling this correctly, according to BUD-01, all errors messages should be on X-Reason header
1 parent 25af8c8 commit d92b69c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/uploaders/blossom.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ export async function uploadBlossom(options: BlossomOptions): Promise<UploadTask
5353
authorization,
5454
},
5555
})
56-
const data = await res.json()
5756
if (res.status !== 200) {
58-
throw new Error((data as BlossomResponseError).message)
57+
const reason = res.headers.get('X-Reason')
58+
throw new Error(reason || 'Error on blossom upload')
5959
}
60+
const data = await res.json()
6061
const { nip94, ...json } = data as BlossomResponse
6162
// Always append file extension if missing
6263
const { pathname } = new URL(json.url)

0 commit comments

Comments
 (0)