mirror of
https://github.com/Brandon-Rozek/website-theme.git
synced 2025-07-29 13:12:00 +00:00
Error handling
This commit is contained in:
parent
0df997d594
commit
cc623bd90a
1 changed files with 12 additions and 3 deletions
|
@ -38,9 +38,14 @@
|
|||
{{ $resource := resources.GetRemote $apiUrl }}
|
||||
{{ $initialCount := 0 }}
|
||||
{{ if $resource }}
|
||||
{{ $highfiveData := $resource | transform.Unmarshal }}
|
||||
{{ if $highfiveData.count }}
|
||||
{{ $initialCount = $highfiveData.count }}
|
||||
{{ with $resource.Err }}
|
||||
{{ warnf "Failed to fetch highfive data from %s: %s" $apiUrl . }}
|
||||
{{ $initialCount = 0 }}
|
||||
{{ else }}
|
||||
{{ $highfiveData := $resource | transform.Unmarshal }}
|
||||
{{ if $highfiveData.count }}
|
||||
{{ $initialCount = $highfiveData.count }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
|
@ -117,6 +122,10 @@
|
|||
return { ...data, alreadyHighFived: true };
|
||||
}
|
||||
|
||||
if (response.status === 400) {
|
||||
return {count: 0}
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue