Skip to content

Commit

Permalink
chore: update error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bowman2001 committed Jan 10, 2024
1 parent ed2aacc commit c12398b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/bowman2001/hugo-mod-resource

go 1.21.0

require github.com/bowman2001/hugo-mod-error-message v0.0.0-20230828202921-a80cf9b12869 // indirect
require github.com/bowman2001/hugo-mod-error-message v0.3.0 // indirect
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ github.com/bowman2001/hugo-mod-error-message v0.0.0-20230827105339-00c160f7b8ba
github.com/bowman2001/hugo-mod-error-message v0.0.0-20230827105339-00c160f7b8ba/go.mod h1:s473WVJh6WZSTryMc/OSxp5F1pRAoMw73ClzmbUcbRk=
github.com/bowman2001/hugo-mod-error-message v0.0.0-20230828202921-a80cf9b12869 h1:7KwUAvBgPzUM60+Mmwj3fc2MHIqYpa/op8C7wbB9XaE=
github.com/bowman2001/hugo-mod-error-message v0.0.0-20230828202921-a80cf9b12869/go.mod h1:s473WVJh6WZSTryMc/OSxp5F1pRAoMw73ClzmbUcbRk=
github.com/bowman2001/hugo-mod-error-message v0.3.0 h1:16Osd3j9FYHVdinWTTSL5sww5tcbiNvmcQQYhy2Imzw=
github.com/bowman2001/hugo-mod-error-message v0.3.0/go.mod h1:qOtBS8WaRgnWHFVWXqvah1V2bYYWX4sUD7l524QJrgU=
6 changes: 3 additions & 3 deletions layouts/partials/mod-resource/func/get-with-params.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
{{- with resources.GetRemote $url.String }}
{{- with .Err }}
{{- $msg := print $errorMsg ". " . }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- else }}
{{- $map = dict "resource" . }} {{- /* no params possible */}}
{{ end }}
{{- else }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- end }}
{{- else }}
{{- $path := (strings.TrimPrefix "./" $url.Path ) }}
Expand All @@ -40,7 +40,7 @@
{{- with resources.Get $url.Path }} {{- /* Site */}}
{{- $map = dict "resource" . }} {{- /* no params possible */}}
{{- else }} {{- /* $map is still empty */}}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/mod-resource/func/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
{{- with resources.GetRemote $url.String }}
{{- with .Err }}
{{- $msg := print $errorMsg ". " . }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- else }}
{{- $r = . }}
{{ end }}
{{- else }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- end }}
{{- else }}
{{- $path := (strings.TrimPrefix "./" $url.Path ) }}
Expand All @@ -31,7 +31,7 @@
{{- with resources.Get $url.Path }} {{- /* Site */}}
{{- $r = . }}
{{- else }} {{- /* $r is still empty */}}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $errorMsg "errorLevel" $errorLevel) }}
{{- end }}
{{- end }}
{{- end }}
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/mod-resource/func/helper/get-from-file.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{- $url = urls.Parse $params.src }}
{{ else }}
{{- $msg := printf "Missing 'src' parameter in the data file %q" $file }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{ end }}

{{- $r := "" }}
Expand All @@ -23,7 +23,7 @@
{{- with resources.GetRemote $url.String }}
{{- with .Err }}
{{- $msg := print $msg ". " . }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel ) }}
{{- else }}
{{- $r = . }}
{{ end }}
Expand All @@ -43,7 +43,7 @@
{{- $map = (dict "resource" . "params" $params) }}
{{- else }}
{{- $msg := printf "Can't find a resource in the data file %q" $file }}
{{- partial "md-error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel) }}
{{- partial "error-msg" (dict "caller" $name "ctx" $ctx "errorMsg" $msg "errorLevel" $errorLevel) }}
{{- end }}
{{- end }}

Expand Down

0 comments on commit c12398b

Please sign in to comment.