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.
This commit is contained in:
St John Karp 2019-03-25 16:23:19 +00:00
parent 7fc59f1c58
commit 71ea1c3084
4 changed files with 40 additions and 3 deletions

View File

@ -231,9 +231,21 @@ class StatusController extends Controller
session()->flash('delete_status', $status_id);
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,

View File

@ -101,6 +101,6 @@ nav ul li {
margin-top: 0;
}
p.warning {
div.warning {
color: red;
}

View File

@ -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])

View File

@ -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>