Skip to content

Throw SettingsMisuse for calls the package cannot serve - #25

Merged
imanimanyara merged 1 commit into
mainfrom
feat/misuse-exception
Nov 16, 2026
Merged

imanimanyara merged 1 commit into
mainfrom
feat/misuse-exception

Conversation

@imanimanyara

Copy link
Copy Markdown
Member

Summary

  • New SettingsMisuse (extends LogicException) replaces the five plain LogicException throws: Lookup::value() on a missing or redacted lookup, flush() without for($owner), Settings::fake() with no application, and a settings migration before the provider is registered. Messages are unchanged, and catch (LogicException $e) still catches them.
  • New SettingsError interface, implemented by SettingsException and SettingsMisuse, so one catch (SettingsError $e) takes every settings exception. SettingsException still extends RuntimeException.
  • Guards: tests/Feature/MisuseTest.php checks each of the five call sites, that every class in src/Exceptions implements SettingsError (31 at least), and scans src (300+ files) for a bare LogicException. The scan failed on the old code first. Pest's arch() cannot see built-in classes, so the scan reads the source.
  • Docs: tools/exceptions.md (reference rows, a catch-all example), tools/settings-api.md, CHANGELOG [Unreleased].

Local: 748 tests pass; Pint, PHPStan level max and Rector clean.

The five plain LogicException throws become SettingsMisuse, which still extends LogicException, so existing catch blocks keep working. A new SettingsError interface, implemented by SettingsMisuse and SettingsException, lets one catch take every settings exception. A source scan keeps bare LogicException out of src; it failed on the old code first.
@imanimanyara
imanimanyara merged commit 2f4524a into main Nov 16, 2026
14 checks passed
@imanimanyara
imanimanyara deleted the feat/misuse-exception branch November 16, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant