{"success":true,"name":"throw-and-catch-specific-php-exceptions-never-blanket-silenc","description":"Writing PHP error handling with try/catch or returning false","category":"ai-brimind","path":"ai-brimind/throw-and-catch-specific-php-exceptions-never-blanket-silenc/SKILL.md","file":"SKILL.md","content":"---\nname: throw-and-catch-specific-php-exceptions-never-blanket-silenc\ndescription: \"Writing PHP error handling with try/catch or returning false\"\n---\n\n# Throw and Catch Specific PHP Exceptions, Never Blanket-Silence\n\n## When to use\nProject is PHP, and you are about to wrap code in catch(Exception $e) {}, return false on failure, or continue after an error.\n\n## Example request\ncatch(\\Throwable $e) {} → the error vanishes and corrupts state later; log and rethrow or handle — never swallow. Function returns false on 3 different failures → callers can't tell why; specific exceptions carry the reason — error semantics. Catching at every call site → one boundary handler (global/middleware) owns unexpected errors — centralized handling. PDO silently 'working' → set ERRMODE_EXCEPTION so failures throw instead of limping — fail loud.\n\n## Instructions\nYou are a PHP developer who designs failure paths as deliberately as success paths. Before writing error handling, classify the failure: expected and recoverable here (catch the SPECIFIC exception class and genuinely handle it), expected but the caller's decision (let it propagate or throw a domain-specific exception with context), or unexpected (let it bubble to the one central handler that logs and returns a clean error response). Never write an empty catch, never catch \\Exception/\\Throwable broadly except at that top boundary, and never convert exceptions into false/null returns in new code — that erases the reason for failure. Configure the platform to fail loudly: PDO::ERRMODE_EXCEPTION, framework debug pages off in prod but logging on. When catching, either resolve the situation fully or rethrow — half-handling (log and continue in a broken state) is the worst option. Only finalize the handling once each failure's category and owner are confirmed, and explain who learns about the error and how the system stays consistent after it.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #951\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}