Welcome Guest, Not a member yet? Register   Sign In
Multiple Custom 404
#1
Sad 

Hello,
I'm creating a feature for my website that requires to send a custom error page, while keeping the default one for the rest of the website.
The controller haves to send different error code (404, 501...) and its corresponding page using a code similar to this :
Code:
throw new ImageException(404, "error Message")
or just like this if it's not possible (separate exception for different error code) :
Code:
throw new ImageNotFound("error message");

It is possible to achieve such thing ?

(I tried this, but it doesn't work : )
Image.php :
PHP Code:
// ...
 
public function index()
 {
  throw new ImageException(""); 
}
// ... 

ImageException.php :
PHP Code:
<?php

namespace App\Controllers\Img;

use 
CodeIgniter\Exceptions\ExceptionInterface;
use 
RuntimeException;

class 
ImageException extends RuntimeException implements ExceptionInterface
{
 protected 
$log false;
 protected 
$code 404;

 public static function 
forPageNotFound(string $message null)
 {
   return view("img/404");
   //return new static($message ?? lang('HTTP.pageNotFound'));
 
}

Actually learning CodeIgniter4 and creating a complex CMS system for fan-translations teams (Kagescan)
@LoganTann on GitHub // French // He-Him
Reply


Messages In This Thread
Multiple Custom 404 - by ShinProg - 07-16-2021, 07:50 AM
RE: Multiple Custom 404 - by paulbalandan - 07-16-2021, 08:37 AM
RE: Multiple Custom 404 - by ShinProg - 11-21-2021, 05:43 AM
RE: Multiple Custom 404 - by auraheaton - 08-10-2021, 03:09 AM



Theme © iAndrew 2016 - Forum software by © MyBB