Skip to content

Commit 209d33e

Browse files
committed
Show a better message for geoblocked storyfiles (curiousdannii/parchment#195)
1 parent 655b092 commit 209d33e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/dialog/browser/download.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,13 @@ async function fetch_storyfile(options: DownloadOptions, url: string, progress_c
136136
}
137137

138138
if (!response.ok) {
139+
if (response.status === 451) {
140+
let message = '<p>Storyfile is unavailable for legal reasons'
141+
if (response.headers.get('Content-type')?.startsWith('text/html')) {
142+
message += `<p>The server might have <a href='${encodeURI(response.url)}'>more information</a>`
143+
}
144+
throw message
145+
}
139146
throw new Error(`Could not fetch storyfile, got ${response.status}`)
140147
}
141148

0 commit comments

Comments
 (0)