Use try function
This commit is contained in:
@@ -6,11 +6,13 @@
|
|||||||
{{ $result := "" }}
|
{{ $result := "" }}
|
||||||
|
|
||||||
{{ if (urls.Parse $url).Scheme }}
|
{{ if (urls.Parse $url).Scheme }}
|
||||||
{{ with resources.GetRemote $url }}
|
{{ with try (resources.GetRemote $url) }}
|
||||||
{{ with .Err }}
|
{{ with .Err }}
|
||||||
{{ errorf "layouts/partials/paige/resource.html: cannot get remote resource %q: %v" $url . }}
|
{{ errorf "layouts/partials/paige/resource.html: cannot get remote resource %q: %v" $url . }}
|
||||||
{{ else }}
|
{{ else with .Value }}
|
||||||
{{ $result = . }}
|
{{ $result = . }}
|
||||||
|
{{ else }}
|
||||||
|
{{ errorf "layouts/partials/paige/resource.html: remote resource %q not found" $url }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@@ -5,12 +5,12 @@
|
|||||||
{{- errorf "layouts/shortcodes/paige/request.html: no url" -}}
|
{{- errorf "layouts/shortcodes/paige/request.html: no url" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- with resources.GetRemote $url (dict "method" $method) -}}
|
{{- with try (resources.GetRemote $url (dict "method" $method)) -}}
|
||||||
{{- with .Err -}}
|
{{- with .Err -}}
|
||||||
{{- errorf "layouts/shortcodes/paige/request.html: cannot request remote resource %q: %v" $url . -}}
|
{{- errorf "layouts/shortcodes/paige/request.html: cannot request remote resource %q: %v" $url . -}}
|
||||||
|
{{- else with .Value -}}
|
||||||
|
{{- strings.TrimRight "\f\n\r\t\v " . -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- strings.TrimRight "\f\n\r\t\v " .Content -}}
|
{{- errorf "layouts/shortcodes/paige/request.html: remote resource %q not found" $url -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- else -}}
|
|
||||||
{{- errorf "layouts/shortcodes/paige/request.html: cannot request remote resource %q" $url -}}
|
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
Reference in New Issue
Block a user