From 26901f82220fe18c0ad6e2bfc23c59b451a4e198 Mon Sep 17 00:00:00 2001 From: Frankie B Date: Fri, 8 Sep 2023 23:19:40 +0100 Subject: feat: add error handling (#14) * Remove commented out crap * Update theme to use some colors from catppuccin, add error handling for API/DB --- resources/views/pages/music.blade.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'resources/views/pages/music.blade.php') diff --git a/resources/views/pages/music.blade.php b/resources/views/pages/music.blade.php index 3e97daa..775157a 100644 --- a/resources/views/pages/music.blade.php +++ b/resources/views/pages/music.blade.php @@ -7,6 +7,19 @@ $cfg = app('config')->get('services')['lastfm']; $api_root = app('config')->get('app')['api_root']; + $api_alive = true; + + try { + $data = file_get_contents($api_root.'/lastfm/current'); + } catch (Exception $e) { + $api_alive = false; + } + @endphp + @if (!$api_alive) + @include('components.errors.api-error') + @else + + @php $current_track = json_decode(file_get_contents($api_root . '/lastfm/current')); $top_tracks = json_decode(file_get_contents($api_root . '/lastfm/top')); $count = 0; @@ -51,4 +64,5 @@ @endforeach + @endif @stop -- cgit v1.2.3-54-g00ecf