Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace error handling in GetRemote with try #13216

Closed
bep opened this issue Jan 5, 2025 · 0 comments · Fixed by #13217
Closed

Replace error handling in GetRemote with try #13216

bep opened this issue Jan 5, 2025 · 0 comments · Fixed by #13217
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Jan 5, 2025

See #9797

Unfortunately this is hard to deprecate. Fortunately the breakage will be loud and should be simple to fix. So for the example in docs:

{{ $url := "https://example.org/images/a.jpg" }}
{{ with resources.GetRemote $url }}
  {{ with .Err }}
    {{ errorf "%s" . }}
  {{ else }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ end }}
{{ else }}
  {{ errorf "Unable to get remote resource %q" $url }}
{{ end }}

Will need to be rewritten to:

{{ $url := "https://example.org/images/a.jpg" }}
{{ with try (resources.GetRemote $url) }}
  {{ with .Err }}
    {{ errorf "%s" . }}
  {{ else with .Value }}
    <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
  {{ else }}
      {{ errorf "Unable to get remote resource %q" $url }}
  {{ end }}
{{ end }}
@bep bep added the Proposal label Jan 5, 2025
@bep bep added this to the v0.141.0 milestone Jan 5, 2025
@bep bep self-assigned this Jan 5, 2025
@bep bep pinned this issue Jan 5, 2025
@bep bep added Enhancement and removed Proposal labels Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 5, 2025
bep added a commit to bep/hugo that referenced this issue Jan 6, 2025
bep added a commit to bep/hugo that referenced this issue Jan 6, 2025
@bep bep closed this as completed in #13217 Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant