Skip to content

Investigate options for sniffs for catching exceptions. #209

Open
@herregroen

Description

@herregroen

With the 14.0 release we ran into unfortunate issues where we were not catching all our own exceptions, thus leading to fatals.

Because of this we'd like to explore options for sniffs that forbid the usage of functions that can throw exceptions without using try and catch.

So the following would be invalid code:

function_that_can_throw_exception();

With the following being a valid replacement;

try {
  function_that_can_throw_exception();
}
catch( Exception $e ) {
  // Anything, possibly even rethrowing the exception with added context.
  // In which case this function can't be used without catching it.
}

Even rethrowing the exception would help with developer awareness that exceptions have to be dealt with and can't simply be left.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions