website/errors/catch.internalInterface.md
<?php declare(strict_types = 1);
namespace Vendor {
/** @internal */
interface InternalExceptionInterface {}
}
namespace App {
function doFoo(): void
{
try {
throw new \Exception();
} catch (\Vendor\InternalExceptionInterface $e) {
}
}
}
A catch block references an interface that is marked as @internal. Internal types are not meant to be used outside of the package or namespace where they are defined. Catching internal interfaces creates a dependency on implementation details that may change without notice in future versions.
Catch a public (non-internal) exception type instead:
try {
throw new \Exception();
-} catch (\Vendor\InternalExceptionInterface $e) {
+} catch (\RuntimeException $e) {
}
If the library provides a public exception class or interface for this purpose, catch that instead.