---
title: "Exceptions & messages — Comments for Laravel | Roundly"
description: "Every failure is a typed CommentsException with a translatable message — catch the base class, or handle each case."
url: https://roundly-consulting.com/open-source/docs/comments-for-laravel/exceptions
language: en
---

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

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

# Exceptions & messages

All exceptions extend the abstract RoundlyConsulting\\Comments\\Exceptions\\CommentsException, itself a RuntimeException:

| Exception | Thrown when |
| --- | --- |
| `InvalidCommentBodyException` | The body is empty after trimming, or longer than max\_length. |
| `MaxReplyDepthExceededException` | A reply would be nested deeper than max\_depth. |
| `CommentRejectedException` | The body matches the blocklist with the reject action. |
| `CommentsLockedException` | Writing or editing against a locked subject or inside a locked thread, or transferring comments onto a locked subject. |
| `InvalidCommentParentException` | A reply’s parent belongs to another subject. |
| `InvalidCommentMetaPathException` | whereMeta() or whereMetaMissing() gets a path that is not lowercase dot notation. |
| `InvalidCommentTransferException` | Comments::transfer() targets the subject the comments already belong to. |
| `UnauthorizedCommentActionException` | The Gate denies an ability while authorization is on. |

A misconfigured setting is the one failure outside this hierarchy: it throws RoundlyConsulting\\PackageToolkit\\Exceptions\\InvalidConfigurationException from the package toolkit, naming the key — see Configuration.

## Translating messages

Exception messages come from the package’s language files, shipped in English (en) and Slovak (sk) with identical keys. Publish them to lang/vendor/comments to reword the keys, or add a folder per locale next to en and sk for another language:

```bash
php artisan vendor:publish --tag="comments-translations"
```

```php
// lang/vendor/comments/en/comments.php
return [
    'body_empty' => 'A comment body cannot be empty.',
    'body_too_long' => 'A comment body cannot be longer than :max characters.',
    'max_depth_exceeded' => 'A reply cannot be nested deeper than :max levels.',
    'rejected' => 'This comment contains content that is not allowed.',
    'locked' => 'This thread is locked and cannot accept new or edited comments.',
    'foreign_parent' => 'A reply must be posted on the same subject as the comment it replies to.',
    'unauthorized' => 'You are not authorized to perform this comment action.',
    'invalid_meta_path' => 'The comment meta path [:path] is invalid. Use dot-separated segments of lowercase letters, digits and underscores, none of them digits only.',
    'transfer_same_subject' => 'Comments cannot be transferred to the subject they already belong to.',
];
```

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