diff --git a/app/Http/Controllers/TrackerController.php b/app/Http/Controllers/TrackerController.php index 515d68f..6013a9d 100644 --- a/app/Http/Controllers/TrackerController.php +++ b/app/Http/Controllers/TrackerController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use DateTime; use App\Mail\WeeklyDigest; use GuzzleHttp\Client; +use GuzzleHttp\Exception\ConnectException; use Illuminate\Http\Request; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; @@ -42,7 +43,16 @@ class TrackerController extends Controller $toCheckin = $request->input('to', null); $forceDownload = $request->input('force', false); - $tripData = $this->get_trip_data($tripId, $forceDownload); + try { + $tripData = $this->get_trip_data($tripId, $forceDownload); + } catch (ConnectException) { + return view( + 'error', + [ + 'message' => "App timed out whilst downloading trip data from Wayward's servers. They may be down currently." + ] + ); + } if ($fromCheckin) { $tripData->checkins = array_filter( @@ -143,6 +153,7 @@ class TrackerController extends Controller 'base_uri' => 'https://app.wayward.travel/', 'timeout' => 20.0 ]); + $response = $client->get('trip/'.($tripId ?? config('app.current_trip_id')).'/user/zmld8ko6qy7d9j3xvq10/json'); switch ($response->getStatusCode()) { @@ -177,8 +188,6 @@ class TrackerController extends Controller return $data->trip; default: - // TODO: Add proper error handling. - return "Something went wrong"; } } diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php new file mode 100644 index 0000000..447fcd9 --- /dev/null +++ b/resources/views/error.blade.php @@ -0,0 +1,14 @@ + + + @include('partials.head') + +
+ +{{ $message }}
+[This video has not yet been uploaded, try again later.]
'; + } } elseif (preg_match("/\.ogg/", $filepath[1])) { - $embed = ''; + if (file_exists(public_path() . "/audio/" . $filepath[1])) { + $embed = ''; + } else { + $embed = '[This audio recording has not yet been uploaded, try again later.]
'; + } } $checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note); }