Skip to content

Commit 4f674f0

Browse files
committed
feat(getEml): Dispara erro se não conseguir pegar o Eml
1 parent 84831d7 commit 4f674f0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/lib/dwca.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ type OuterEml = {
345345
} & RU
346346
const extractEml = (OuterEml: OuterEml) => OuterEml['eml:eml']
347347
export const getEml = async (url: string) => {
348-
const contents = await fetch(url).then((res) => res.text())
348+
const contents = await fetch(url).then((res) => {
349+
if (!res.ok) {
350+
throw new Error(res.statusText)
351+
}
352+
return res.text()
353+
})
349354
return extractEml(parse(contents) as OuterEml)
350355
}
351356

0 commit comments

Comments
 (0)