Skip to content

Commit

Permalink
Error if a README couldn't be found (#1167)
Browse files Browse the repository at this point in the history
* Error if a README couldn't be found

GetRemote returns nil not an error in this case

* Fail the build on unrecognised block types

This should be very rare, but always points at a significant error we
need to fix.
  • Loading branch information
illicitonion authored Nov 1, 2024
1 parent 13934ee commit fcb2676
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common-theme/layouts/partials/block/block.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
{{ else if eq $blockData.type "link" }}
{{ partial "block/link.html" . }}
{{ else }}
<p>Error: {{ $blockData.type }} Unrecognized block type</p>
{{ errorf "Unrecognized block type %s" $blockData.type }}
{{ end }}
10 changes: 9 additions & 1 deletion common-theme/layouts/partials/block/readme.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{{ $blockData := .Page.Scratch.Get "blockData" }}

{{ $pageContext := . }}
{{ with resources.GetRemote $blockData.api $blockData.headers }}
{{ $response := resources.GetRemote $blockData.api $blockData.headers }}

{{/* 404s lead to GetRemote returning nil rather than an error. */}}
{{ if eq $response nil }}
{{ errorf "Couldn't find readme at %s" $blockData.api }}
{{ end }}

{{ with $response }}
{{ with .Err }}
{{ errorf "Failed %s on %s. Error: %s" $blockData.api .Page.Title .Err }}
{{ end }}
Expand Down

0 comments on commit fcb2676

Please sign in to comment.