,

How to catch PHP errors o WordPress

0 0 votes Article Rating

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
0 0 votes
Article Rating
try {

// code

    
} catch (\Exception $e) {
    wp_die('<h1 style="color:red;">Exception:</h1> ' . $e->getMessage());
} catch (\Error $e) {
    wp_die('<h1 style="color:red;">PHP Fatal Error:</h1> ' . $e->getMessage() . ' file ' . $e->getFile() . ' line ' . $e->getLine());
}
0
Would love your thoughts, please comment.x
()
x