---
title: "Exceptions — Contacts for Laravel | Roundly"
description: "Every exception the package throws, when it is thrown, and how to catch them all through the ContactException base class."
url: https://roundly-consulting.com/open-source/docs/contacts-for-laravel/exceptions
language: en
---

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

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

# Exceptions

All package exceptions live in RoundlyConsulting\\Contacts\\Exceptions and extend ContactException:

| Exception | Thrown when |
| --- | --- |
| `ContactException` | Abstract base (extends RuntimeException) — catch it to handle every package error. |
| `InvalidContactValue` | add(), update() or sync() got a value that fails its kind’s rules after normalization or exceeds 255 characters — or a structured address on a contact that is not an address. |
| `InvalidVerificationToken` | verification()->confirm() with a wrong token, when none was issued, or after the token was voided. |
| `VerificationAttemptsExceeded` | The wrong guess that spent the token’s last attempt (max\_attempts); the token is voided. Extends InvalidVerificationToken. |
| `VerificationExpired` | The token matched but is past its TTL. |
| `PrimaryContactConflict` | require\_owner\_for\_primary is on and an ownerless contact is made primary — or a soft-deleted contact is made primary. |
| `RelationshipException` | relateTo() with a kind outside relationship\_kinds, or a contact related to itself. |

```php
use RoundlyConsulting\Contacts\Exceptions\ContactException;

try {
    $user->addPhone($request->string('phone')->toString());
} catch (ContactException $e) {
    return back()->withErrors(['phone' => $e->getMessage()]);
}
```

InvalidContactValue, InvalidVerificationToken, VerificationAttemptsExceeded and VerificationExpired use the contacts::errors translations — invalid\_value, structured\_address\_kind, invalid\_verification\_token, verification\_attempts\_exceeded and verification\_expired — shipped in English and Slovak, so you can reword them or add another language by publishing contacts-translations. PrimaryContactConflict and RelationshipException carry plain English messages.

A malformed config value — a verification style, TTL, length or attempt count, the table, the country code, the model, key\_type or a types / relationship\_kinds entry — is not a ContactException: it throws RoundlyConsulting\\PackageToolkit\\Exceptions\\InvalidConfigurationException naming 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/contacts-for-laravel.md)
