---
title: "Errors & translations — QR for Laravel | Roundly"
description: "One exception hierarchy with stable reason keys, translatable user-facing messages, and the publishable translation file."
url: https://roundly-consulting.com/open-source/docs/qr-for-laravel/errors
language: en
---

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

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

# Errors & translations

Every exception extends the abstract QrException (a RuntimeException) and exposes a stable $reason key and the $field it concerns. Messages are fixed English developer messages without payload values; show end users the translated message instead:

```php
use RoundlyConsulting\Qr\Exceptions\QrException;

try {
    $svg = Qr::wifi($ssid, $password)->svg();
} catch (QrException $e) {
    $e->reason;   // stable key, e.g. 'too_short'
    $e->field;    // e.g. 'password' — never the value

    return back()->withErrors([
        'wifi' => __('qr::qr.errors.'.$e->reason, ['field' => $e->field]),
    ]);
}
```

## Hierarchy and reason keys

```
QrException (abstract)
├── DataTooLongException            data_too_long, input_too_long
├── InvalidOptionException          version_range, mask, size, margin, radius, attribute, error_correction,
│   │                               locked_by_payload, out_of_bounds, eci, render_as
│   └── InvalidColorException       color
├── InvalidQrConfigException        invalid_config ($field = config key)
├── UnencodableCharacterException   unencodable_character
├── InvalidPayloadException         required, too_long, too_short, invalid_format, out_of_range,
│   │                               unsupported_scheme, mutually_exclusive, unsupported_in_version, unrepresentable
│   ├── InvalidIbanException        iban_format, iban_country, iban_length, iban_checksum
│   ├── InvalidBicException         bic_format, bic_country
│   ├── InvalidCreditorReferenceException  creditor_reference_format, creditor_reference_checksum
│   ├── UnsupportedCurrencyException       currency_not_eur, currency_not_iso, currency_mismatch
│   └── PaymentPayloadTooLongException     payload_too_long
├── BySquareDecodeException         bysquare_base32hex, _header, _length, _lzma, _crc, _fields, _value
│   └── CorruptLzmaStreamException  bysquare_lzma
└── MatrixDecodeException           decode_size, decode_format, decode_version, decode_error_correction, decode_segment
```

DataTooLongException additionally carries neededBits, capacityBits, minVersion, maxVersion and errorCorrection; InvalidPayloadException carries $payloadType.

## Translations

English and Slovak ship — resources/lang/{en,sk}/qr.php under the qr namespace, with identical keys and placeholders. Publish them with the qr-translations tag only to reword them or add a language:

- qr::qr.title — the default accessible title (“QR code”).
- qr::qr.descriptions.{text, url, email, phone, sms, wifi, vcard, geo, otpauth, epc, bysquare} — the default <desc> per payload type; url uses :host.
- qr::qr.validation.{iban, iban\_eea, bic, creditor\_reference, fits\_in\_qr\_code} — the rule messages.
- qr::qr.errors.<reason> — one user-facing message per exception reason key (locked\_by\_payload: “The :field option is fixed by this content type.”).

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