---
title: "Exceptions — Translatable for Laravel | Roundly"
description: "Every package error extends TranslatableException — malformed locale keys, non-scalar values, unloaded columns and non-translatable attributes."
url: https://roundly-consulting.com/open-source/docs/translatable-for-laravel/exceptions
language: en
---

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

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

# Exceptions

All of the package’s own exceptions extend TranslatableException, so you can catch the whole family with the base class. Only a misconfigured setting throws the toolkit’s InvalidConfigurationException instead, and a read of an unloaded column under preventAccessingMissingAttributes() throws Eloquent’s MissingAttributeException:

| Exception | Thrown when |
| --- | --- |
| `TranslatableException` | Base class (a RuntimeException). Thrown directly when a locale map can’t be JSON-encoded (e.g. invalid UTF-8) or a search field isn’t a plain identifier. |
| `NotATranslatableAttributeException` | A translation method or scope was called for an attribute not listed in $translatable. |
| `InvalidLocaleException` | A locale key on a write path, a scope, Translatable::ensureLocale() or a per-model $translatableFallbackLocale is malformed (a trailing newline included) — or isn’t supported while strict\_locales (or strict: true) is on. |
| `TranslationsNotLoadedException` | One locale is written on a model loaded without that column (see Reading and writing). |
| `InvalidTranslationValueException` | A value isn’t a string, int or float — a nested array, object or boolean. |
| `RoundlyConsulting\PackageToolkit\Exceptions\InvalidConfigurationException` | A config value is unusable — fallback outside none/fallback/any, strict\_locales outside the boolean words, a malformed fallback\_locale, or locales that isn’t a list of well-formed locale keys. The message names the key. Also a per-model $translatableFallbackMode that names no mode, or a non-string $translatableFallbackLocale. |

```php
use RoundlyConsulting\Translatable\Exceptions\InvalidLocaleException;
use RoundlyConsulting\Translatable\Exceptions\TranslatableException;

try {
    $topic->setTranslations('name', $payload);
} catch (InvalidLocaleException $e) {
    // malformed key, or an unsupported locale while strict_locales is on
} catch (TranslatableException $e) {
    // any other package error
}
```

To avoid write-path exceptions from user input altogether, normalise request maps with Translatable::fromInput() or validate them with Translatable::rules() first (see Input and validation). A single locale from a query parameter or route segment goes through Translatable::ensureLocale() or Translatable::isSupported().

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