mirror of https://git.stjo.hn/planiverse
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:
parent
7fc59f1c58
commit
71ea1c3084
|
@ -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,
|
||||
|
|
|
@ -101,6 +101,6 @@ nav ul li {
|
|||
margin-top: 0;
|
||||
}
|
||||
|
||||
p.warning {
|
||||
div.warning {
|
||||
color: red;
|
||||
}
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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>
|
Loading…
Reference in New Issue