---
title: "Exceptions — Addresses for Laravel | Roundly"
description: "One AddressesException base and five typed exceptions — incomplete address, invalid country, foreign address, deleted address and invalid type."
url: https://roundly-consulting.com/open-source/docs/addresses-for-laravel/exceptions
language: en
---

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

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

# Exceptions

All exceptions live in RoundlyConsulting\\Addresses\\Exceptions and extend the abstract AddressesException (itself a RuntimeException), so you can catch the whole family with one type:

| Exception | Thrown by | Message |
| --- | --- | --- |
| `IncompleteAddressException` | PendingAddress::save() when city, street, postalCode or country is missing or blank. | The address is missing required field(s): \[street, country\]. |
| `InvalidCountryException` | AddressData::make() with normalise\_country on, for anything that is not two or three letters. | The value \[XX1\] is not a country code: expected two or three letters (ISO 3166-1 alpha-2 or alpha-3). |
| `AddressOwnershipException` | Addresses::for($owner)->setPrimary() or setPrimaryAddress() with an address owned by another model. | The given address does not belong to this model. |
| `TrashedAddressException` | setPrimary() or setPrimaryAddress() with a soft-deleted address, or Addresses::update() asking a soft-deleted address to become primary. | A deleted address cannot be made primary; restore it first. |
| `InvalidAddressTypeException` | Building an address without a type while default\_type is not an AddressType value — and your own code that converts untrusted strings. | The address type \[foo\] is not a valid AddressType. |
| `AddressesException` | Abstract base of all of the above; extends RuntimeException. | — |
| `InvalidConfigurationException` | The package toolkit’s exception, not an AddressesException — an unrecognised key\_type when the migration runs, a non-boolean normalise\_country, a country\_resolver that does not name a CountryResolver class, or a model that does not extend Address. | Configuration value \[addresses.country\_resolver\] must be a class-string of \[RoundlyConsulting\\Addresses\\Contracts\\CountryResolver\], \[App\\Typo\] given. |

```php
use RoundlyConsulting\Addresses\Exceptions\AddressesException;

try {
    $customer->newAddress()
        ->in($city)->at($street)->postalCode($postalCode)->country($country)
        ->save();
} catch (AddressesException $e) {
    // IncompleteAddressException, InvalidCountryException, …
    report($e);
}
```

## 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/addresses-for-laravel.md)
