Welcome Guest, Not a member yet? Register   Sign In
Error page in production (CI 3)
#1

Hello,
Actually, in production mode, an error will send blank page to user. Is it possible to send a fixed error html page (blank page is ambigous for users), just to say there is an error ?
In advance, thank you.
Reply
#2

I found a temp solution but I don't like it because I modified a file in system directory :

system/core/Common.php :

PHP Code:
function _exception_handler($exception)
 {
    $_error =& load_class('Exceptions''core');
    $_error->log_exception('error''Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine());

    is_cli() OR set_status_header(500);
    // Should we display the error?
    if (str_ireplace(array('off''none''no''false''null'), ''ini_get('display_errors')))
    {
        $_error->show_exception($exception);
    }
    // *** new block ***
    if ( ENVIRONMENT=='production' ) {
        echo $_error->show_error("ERREUR SERVEUR""Une erreur est survenue !");
    }

    exit(1); // EXIT_ERROR

Is there a more conventional way ?
Reply
#3

(This post was last modified: 07-04-2024, 10:19 AM by captain-sensible. Edit Reason: typo )

for use of a "contact us" form the submitted data gets handled in a controller leveraging PHPMailer . I just use a view called info2.php which as :

[CODE}
<?php echo $info;?>

<?php echo $infoException;?>
[/CODE]

I want simple error output if the message doesnt get sent.

In the controller I have



Code:
try

{
//try and send message
}
catch ( \Exception  $e)
                                         {
                                                echo "something went wrong";    
                                         $data = [
                                                    'title'  => 'info',
                                                  
                                               'info'=>'something went wrong with sending message' ,
                                               'infoException'=>$e->getMessage(),
                                               'date'=>$this->myDate,
                                                 ];
                                        
                                            echo view('info2', $data);
                                             die();
                                        
                                            }

So if error is caught i call the view info2.php and pass data to it

im using my gmail to rely out email , when the user name or password is not right as an example the following is output
[CODE}
something went wrong with sending message SMTP Error: Could not authenticate.

[/CODE]

that happened recently ..on a live web in production mode ; key words " could not authenticate" was enough info for me to check user and pass creentials .

with i guess judicious use of try catch in controllers ,you msy be able to set things up for every evenuality
CMS CI4 A CMS system, runs out of the box written on top of CI4
Arch Book  CodeIgniter4 on Apache(pages 92-114) 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB