mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
404 properly when post is not found
This commit is contained in:
parent
d05fd00f73
commit
300b5192e4
2 changed files with 8 additions and 3 deletions
|
@ -85,8 +85,11 @@ class ContentActions extends Actions
|
|||
|
||||
public static function executeNewsPost($relativeUri)
|
||||
{
|
||||
$post = Post::load(ltrim($relativeUri, '/'));
|
||||
if (!$post)
|
||||
try
|
||||
{
|
||||
$post = Post::load(ltrim($relativeUri, '/'));
|
||||
}
|
||||
catch (PostNotFoundException $e)
|
||||
{
|
||||
return ['page/404', []];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
|
||||
class PostNotFoundException extends Exception {}
|
||||
|
||||
class Post
|
||||
{
|
||||
const SORT_DATE_DESC = 'sort_date_desc';
|
||||
|
@ -33,7 +35,7 @@ class Post
|
|||
return static::load($slugMap[$slug]);
|
||||
}
|
||||
}
|
||||
throw new InvalidArgumentException('No post found for path: ' . $relativeOrAbsolutePath);
|
||||
throw new PostNotFoundException('No post found for path: ' . $relativeOrAbsolutePath);
|
||||
}
|
||||
|
||||
list($ignored, $frontMatter, $content) = explode('---', file_get_contents($path), 3);
|
||||
|
|
Loading…
Add table
Reference in a new issue