Skip to content

Fix #50: point DriverNotFoundException at the right cause - #99

Open
corgab wants to merge 2 commits into
mainfrom
fix/50-driver-not-found-message
Open

Fix #50: point DriverNotFoundException at the right cause#99
corgab wants to merge 2 commits into
mainfrom
fix/50-driver-not-found-message

Conversation

@corgab

@corgab corgab commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

DriverNotFoundException::forDriver() always said "Check your 'aether.default' configuration", but QuantumManager::createDriver() is reached both when the default driver is resolved and when a caller names a driver explicitly (Quantum::driver('ionq'), Quantum::circuit('ionq')). The explicit case is the common one during development, a typo or a custom driver that was never registered, and the message sent the developer to a setting they had not touched.

Plan

Distinguish the two cases where the information exists. Illuminate\Support\Manager::driver() resolves a null argument to getDefaultDriver() before calling createDriver($name), so inside createDriver() an unknown name that equals the configured default is a configuration problem, and any other unknown name was requested explicitly. Make the explicit message useful by listing the names that do resolve, taken from the manager rather than hard-coded.

Changes

  • DriverNotFoundException::forDriver(string $name, array $available = []): lists the registered drivers when given, suggests Quantum::extend('<name>', ...) and a possible typo; no longer mentions aether.default.
  • DriverNotFoundException::forDefaultDriver(string $name) (new): says the driver is configured as the default and points at aether.default / AETHER_DRIVER, or at Quantum::extend().
  • QuantumManager::createDriver(): casts the argument once (an int-backed enum arrives as its raw value), refuses to match an empty name against createDriver itself, and picks the factory by comparing with getDefaultDriver(), passing the built-in plus extend()ed names for the explicit case.
  • QuantumManager::getDefaultDriver(): a null or blank aether.default (an empty AETHER_DRIVER= line) falls back to local instead of surfacing as a TypeError or an ArgumentCountError.

No config change, no new dependencies, same exception class in both cases so existing catch blocks are unaffected.

Tests

  • ExceptionHierarchyTest: forDriver() mentions the name and the extend() hint and not aether.default, and lists the registered drivers when given; forDefaultDriver() mentions aether.default and AETHER_DRIVER.
  • QuantumManagerTest: an explicit unknown driver with a valid default blames the name, not the setting; an unknown default blames the setting; the message names an extend()ed driver; a null or blank default resolves to the local driver; an unknown explicit driver with a null default still throws DriverNotFoundException.

Local: pint passed, pest 799 tests passed.

Closes #50

The message always told the developer to check 'aether.default', even
when the unknown name was passed explicitly to Quantum::driver('ionq') or
Quantum::circuit('ionq'), which is the common case during development and
has nothing to do with that setting. Manager resolves a null argument to
the default before createDriver() runs, so an unknown name that equals the
default now blames the aether.default setting, and any other unknown name
points at Quantum::extend() and a possible typo, naming the built-in
drivers.

Closes #50
Comparing the unknown name with getDefaultDriver() exposed two latent
faults: a null aether.default returned null from a string-typed method,
and a blank one made Str::studly('') resolve to createDriver itself. The
default now falls back to 'local' for null or blank values, and an empty
name can no longer match a method. Enum-backed driver arguments arrive as
their raw value, so createDriver() casts once before matching creators or
building the message. The explicit-name message lists the drivers that do
resolve, built-ins and extend()ed ones alike, from the manager instead of
a hard-coded pair.
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.

[exceptions] DriverNotFoundException always blames 'aether.default', even for an explicitly requested driver name

1 participant