1.2.1236. Uncaught Exceptions

The following exceptions are thrown in the code, but are never caught.

Either they will lead to a Fatal Error, or they have to be caught by an including application. This is a valid behavior for libraries, but is not for a final application.

<?php

// This exception is throw, but not caught. It will lead to a fatal error.
if ($message = check_for_error()) {
    throw new My\Exception($message);
}

// This exception is throw, and caught.
try {
    if ($message = check_for_error()) {
        throw new My\Exception($message);
    }
} catch (\Exception $e) {
    doSomething();
}

?>

See also Structuring PHP Exceptions.

1.2.1236.1. Suggestions

  • Catch all the exceptions you throw

1.2.1236.2. Specs

Short name

Exceptions/UncaughtExceptions

Rulesets

All, Analyze, Changed Behavior

Exakat since

0.8.4

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

exception, try-catch

Available in

Entreprise Edition, Exakat Cloud