---
title: "Exceptions — Options for Laravel | Roundly"
description: "Every package exception, when it’s thrown, and the framework exceptions you may also meet."
url: https://roundly-consulting.com/open-source/docs/options-for-laravel/exceptions
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Options for Laravel](https://roundly-consulting.com/open-source/docs/options-for-laravel.md)

# Exceptions

Package exceptions live in RoundlyConsulting\\Options\\Exceptions and extend the abstract OptionException, so one catch handles all of them. The one failure that isn’t an OptionException is a value an option’s rules() refuse — that throws Laravel’s ValidationException (see Validation), so catch it as well:

| Exception | Thrown when |
| --- | --- |
| `InvalidOptionClassName` | A key isn’t registered, or a class doesn’t implement OptionInterface — also for unknown entries in config\_overrides. |
| `InvalidOptionGroup` | A group class isn’t an OptionGroup, or group set() gets an identifier that isn’t a member. |
| `InvalidOptionObserver` | An observer class-string has no \_\_invoke method. |
| `InvalidOptionPayload` | Import JSON is invalid or isn’t an array, a row is neither an array nor an OptionPayload, lacks a string key or has a value that isn’t a string, number, boolean or null; a value isn’t a case of an EnumCast option’s enum; or options:set --json gets invalid JSON. |
| `InvalidOwnerModel` | A CLI --owner isn’t an Eloquent model, --owner-id is missing or names no record, or the --as user can’t be found. |
| `UnauthorizedOption` | Access control denies a read or a write. |
| `EncryptionNotSupported` | encrypted() is true but castAs() returns a cast instance instead of a string. |
| `OptionException` | Never directly — the abstract base of every exception above. |

```php
use Illuminate\Validation\ValidationException;
use RoundlyConsulting\Options\Exceptions\OptionException;
use RoundlyConsulting\Options\Exceptions\UnauthorizedOption;

try {
    Options::set(MaintenanceModeOption::class, true);
} catch (UnauthorizedOption $e) {
    abort(403);
} catch (ValidationException $e) {
    // the value failed the option's rules(); $e->errors()['value']
} catch (OptionException $e) {
    report($e); // any other options error
}
```

## From the framework

- Illuminate\\Validation\\ValidationException — a value fails the option’s rules().
- Illuminate\\Contracts\\Encryption\\DecryptException — encrypted ciphertext was tampered with or the APP\_KEY changed.
- RoundlyConsulting\\PackageToolkit\\Exceptions\\InvalidConfigurationException — a config value is invalid: options.model isn’t Option or a subclass of it, an unknown key\_type, a switch that isn’t a boolean, a cache.ttl that isn’t a whole number of at least 1, or a cache.store, cache.prefix or cache.tag that isn’t a string. The message names the key.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/options-for-laravel.md)
