planiverse

A minimalist, no-JS front-end for Mastodon.
git clone https://git.stjo.hn/planiverse
Log | Files | Refs | README | LICENSE

commit 71ea1c3084510aefc939a136cc94739ed33cf060
parent 7fc59f1c58fa4a88273995970478833160670b50
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Mon, 25 Mar 2019 16:23:19 +0000

Fix #6 - Add error handling for deleting an already deleted status

Added a basic error page and implemented handling for deleting a
status that can't be found.

Diffstat:
Mapp/Http/Controllers/StatusController.php | 14+++++++++++++-
Mpublic/css/styles.css | 2+-
Mresources/views/delete_status.blade.php | 4+++-
Aresources/views/error.blade.php | 23+++++++++++++++++++++++
4 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php @@ -231,9 +231,21 @@ class StatusController extends Controller session()->flash('delete_status', $status_id); - $status = Mastodon::domain(env('MASTODON_DOMAIN')) + try + { + $status = Mastodon::domain(env('MASTODON_DOMAIN')) ->token(session('user')->token) ->get('/statuses/' . $status_id); + } + catch (\GuzzleHttp\Exception\ServerException $ex) + { + $vars = [ + 'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1], + 'message' => 'Status not found.' + ]; + + return view('error', $vars); + } $vars = [ 'status' => $status, diff --git a/public/css/styles.css b/public/css/styles.css @@ -101,6 +101,6 @@ nav ul li { margin-top: 0; } -p.warning { +div.warning { color: red; } diff --git a/resources/views/delete_status.blade.php b/resources/views/delete_status.blade.php @@ -15,7 +15,9 @@ @component('navigation') @endcomponent - <p class="warning">Are you sure you want to delete this status? Click the delete link again to confirm.</p> + <div class="warning"> + <p>Are you sure you want to delete this status? Click the delete link again to confirm.</p> + </div> <ul> @component('status', ['status' => $status]) diff --git a/resources/views/error.blade.php b/resources/views/error.blade.php @@ -0,0 +1,23 @@ +<!doctype html> +<html lang="{{ app()->getLocale() }}"> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <title>{{ $mastodon_domain }} | Error</title> + + <link rel="stylesheet" href="{{ url('css/styles.css') }}" /> + </head> + <body> + <h1>{{ $mastodon_domain }} | Error</h1> + + @component('navigation') + @endcomponent + + <div class="warning"> + <p>Something went wrong…</p> + <p>{{ $message }}</p> + </div> + </body> +</html>