PHP Classes

File: doc/10-exceptions.md

Recommend this page to a friend!
  Classes of Xavier Pérez   XMongoDB   doc/10-exceptions.md   Download  
File: doc/10-exceptions.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: XMongoDB
Build and execute queries to a MongoDB database
Author: By
Last change: Chnages readme
Date: 8 years ago
Size: 734 bytes
 

Contents

Class file image Download

Exceptions

Exceptions can be handled by your code:

function MyExceptionHandler($exception) {
    $message = $exception->getMessage();
    $code = $exception->getCode();
    $previous = $exception->getPrevious();
    $file = $exception->getFile();
    $line = $exception->getLine();
    $trace = $exception->getTrace();

    echo "<h2>EXCEPTION</h2>";
    echo "<hr>";
    echo "Message error: $message - $code <br> File: $file  Line: $line <br>";
    echo "Message orig: ".$previous->getMessage()." - ".$previous->getCode()." <br> File: ".$previous->getFile()."  Line: ".$previous->getLine()." <br>";
    echo "<hr>";
    echo "<h2>TRACE</h2>";
    var_dump($trace);
}

set_exception_handler('MyExceptionHandler');