@@ -349,9 +349,11 @@ function serve_file(
349
349
ret_code = 200
350
350
fs_path, case = get_fs_path (req. target)
351
351
352
- if case == :not_found_without_404
353
- html_404 = pagehtml (title = " 404 Not Found" ) do io
354
- write (io, """
352
+ # Fast paths to execute if building documentation isn't currently failing
353
+ if fw. status != :documenter_jl_error
354
+ if case == :not_found_without_404
355
+ html_404 = pagehtml (title = " 404 Not Found" ) do io
356
+ write (io, """
355
357
<div style="width: 100%; max-width: 500px; margin: auto">
356
358
<h1 style="margin-top: 2em">404 Not Found</h1>
357
359
<p>
@@ -366,26 +368,48 @@ function serve_file(
366
368
</p>
367
369
</div>
368
370
"""
369
- )
371
+ )
372
+ end
373
+ return HTTP. Response (404 , html_404)
374
+ elseif case == :not_found_with_404
375
+ ret_code = 404
376
+ elseif case == :dir_without_index
377
+ index_page = get_dir_list (fs_path)
378
+ return HTTP. Response (200 , index_page)
370
379
end
371
- return HTTP. Response (404 , html_404)
372
- elseif case == :not_found_with_404
373
- ret_code = 404
374
- elseif case == :dir_without_index
375
- index_page = get_dir_list (fs_path)
376
- return HTTP. Response (200 , index_page)
377
380
end
378
381
379
- #
380
- # In what follows, fs_path points to a file
381
- # :dir_with_index
382
- # :file
383
- # :not_found_with_404
384
- # --> html-like: try to inject reload-script
385
- # --> other: just get the browser to show it
386
- #
387
- ext = lstrip (last (splitext (fs_path)), ' .' ) |> string
388
- content = read (fs_path, String)
382
+ ext = nothing
383
+ content = nothing
384
+
385
+ # If building the documentation is failing we return a special error page,
386
+ # otherwise we just read the file from disk.
387
+ if fw. status == :documenter_jl_error
388
+ ret_code = 500
389
+ ext = " html"
390
+ content = pagehtml (title = " Documenter.jl error" ) do io
391
+ write (io, """
392
+ <div style="width: 100%; max-width: 500px; margin: auto">
393
+ <h1 style="margin-top: 2em">Error building docs</h1>
394
+ <p>
395
+ An error occurred when rebuilding the documentation, please check the <code>servedocs()</code> output.
396
+ </p>
397
+ </div>
398
+ """
399
+ )
400
+ end
401
+ else
402
+ #
403
+ # In what follows, fs_path points to a file
404
+ # :dir_with_index
405
+ # :file
406
+ # :not_found_with_404
407
+ # --> html-like: try to inject reload-script
408
+ # --> other: just get the browser to show it
409
+ #
410
+ ext = lstrip (last (splitext (fs_path)), ' .' ) |> string
411
+ content = read (fs_path, String)
412
+ end
389
413
390
414
# build the response with appropriate mime type (this is inspired from Mux
391
415
# https://github.com/JuliaWeb/Mux.jl/blob/master/src/examples/files.jl)
0 commit comments