# Message

> Defines nested sets exception message templates.

[API reference](/docs/api/index.md) › [Nested sets behavior](/docs/extensions/nested-sets-behavior/reference/index.md) › [exception](/docs/extensions/nested-sets-behavior/reference/exception/index.md) › Message

| enum | `yii2\extensions\nestedsets\exception\Message` |
| --- | --- |
| Backed by | `string` |
| Source | [`src/exception/Message.php`](https://github.com/yii2-extensions/nested-sets-behavior/blob/main/src/exception/Message.php#L14) |

Defines nested sets exception message templates.

Use [`Message::getMessage()`](/docs/extensions/nested-sets-behavior/reference/exception/message/index.md#method-getMessage) to format the template with `sprintf()` arguments.

## Cases

| Case | Value | Description |
| --- | --- | --- |
| <span id="case-BEHAVIOR_NOT_ATTACHED"></span>`BEHAVIOR_NOT_ATTACHED` | `'The "owner" property must be set before using the behavior.'` | Error when the behavior is used without an attached owner. |
| <span id="case-CANNOT_CREATE_MULTIPLE_ROOTS"></span>`CANNOT_CREATE_MULTIPLE_ROOTS` | `"Can not create more than one root when 'treeAttribute' is 'false'."` | Error when a second root is created while `treeAttribute` is `false`. |
| <span id="case-CANNOT_CREATE_NODE_TARGET_IS_NEW_RECORD"></span>`CANNOT_CREATE_NODE_TARGET_IS_NEW_RECORD` | `'Can not create a node when the target node is new record.'` | Error when a node is created relative to a new record target. |
| <span id="case-CANNOT_CREATE_NODE_TARGET_IS_ROOT"></span>`CANNOT_CREATE_NODE_TARGET_IS_ROOT` | `'Can not create a node when the target node is root.'` | Error when a sibling of a root node is created. |
| <span id="case-CANNOT_DELETE_NEW_RECORD"></span>`CANNOT_DELETE_NEW_RECORD` | `'Can not delete a node when it is new record.'` | Error when a new record is deleted as a node. |
| <span id="case-CANNOT_MOVE_NODE_AS_ROOT"></span>`CANNOT_MOVE_NODE_AS_ROOT` | `"Can not move a node as the root when 'treeAttribute' is 'false'."` | Error when a node is moved as a root while `treeAttribute` is `false`. |
| <span id="case-CANNOT_MOVE_NODE_TARGET_IS_CHILD"></span>`CANNOT_MOVE_NODE_TARGET_IS_CHILD` | `'Can not move a node when the target node is child.'` | Error when a node is moved relative to one of its descendants. |
| <span id="case-CANNOT_MOVE_NODE_TARGET_IS_NEW_RECORD"></span>`CANNOT_MOVE_NODE_TARGET_IS_NEW_RECORD` | `'Can not move a node when the target node is new record.'` | Error when a node is moved relative to a new record target. |
| <span id="case-CANNOT_MOVE_NODE_TARGET_IS_ROOT"></span>`CANNOT_MOVE_NODE_TARGET_IS_ROOT` | `'Can not move a node when the target node is root.'` | Error when a node is moved as a sibling of a root node. |
| <span id="case-CANNOT_MOVE_NODE_TARGET_IS_SAME"></span>`CANNOT_MOVE_NODE_TARGET_IS_SAME` | `'Can not move a node when the target node is same.'` | Error when a node is moved relative to itself. |
| <span id="case-CANNOT_MOVE_ROOT_AS_ROOT"></span>`CANNOT_MOVE_ROOT_AS_ROOT` | `'Can not move the root node as the root.'` | Error when a root node is moved as a root. |
| <span id="case-CANNOT_READ_SQLITE_BUSY_TIMEOUT"></span>`CANNOT_READ_SQLITE_BUSY_TIMEOUT` | `'Cannot read SQLite busy timeout.'` | Error when the SQLite busy timeout cannot be read. |
| <span id="case-CANNOT_READ_SQLSRV_LOCK_TIMEOUT"></span>`CANNOT_READ_SQLSRV_LOCK_TIMEOUT` | `'Cannot read SQL Server lock timeout.'` | Error when the SQL Server lock timeout cannot be read. |
| <span id="case-CANNOT_REGISTER_WRITER_ROW"></span>`CANNOT_REGISTER_WRITER_ROW` | `'Cannot register the nested set writer row.'` | Error when the writer registry row cannot be registered. |
| <span id="case-CANNOT_RESOLVE_MYSQL_IDENTIFIER_CASE"></span>`CANNOT_RESOLVE_MYSQL_IDENTIFIER_CASE` | `'Cannot resolve MySQL identifier case rules.'` | Error when the MySQL identifier case mode cannot be resolved. |
| <span id="case-CANNOT_RESOLVE_SQLSRV_DATABASE"></span>`CANNOT_RESOLVE_SQLSRV_DATABASE` | `'Cannot resolve the SQL Server database.'` | Error when the SQL Server database cannot be resolved. |
| <span id="case-DELETE_ROOT_NOT_SUPPORTED"></span>`DELETE_ROOT_NOT_SUPPORTED` | `"Method '%s::delete' is not supported for deleting root nodes."` | Error when a root node is deleted outside `deleteWithChildren()` for a specific class. |
| <span id="case-INSERT_NOT_SUPPORTED"></span>`INSERT_NOT_SUPPORTED` | `"Method '%s::insert' is not supported for inserting new nodes."` | Error when a node is inserted without a pending operation for a specific class. |
| <span id="case-INVALID_TABLE_METADATA"></span>`INVALID_TABLE_METADATA` | `'Invalid nested set table metadata.'` | Error when the catalog row holds non-scalar table metadata. |
| <span id="case-LOCK_BOOTSTRAP_ROW_MISSING"></span>`LOCK_BOOTSTRAP_ROW_MISSING` | `"Missing nested set bootstrap row. Apply 'm261016_000001_nested_sets_lock' in the " . 'model table schema.'` | Error when the writer lock bootstrap row is missing. |
| <span id="case-LOCK_DRIVER_NOT_SUPPORTED"></span>`LOCK_DRIVER_NOT_SUPPORTED` | `'Nested set writer locking is not implemented for this database driver.'` | Error when writer locking is not implemented for the database driver. |
| <span id="case-LOCK_REQUIRES_INNODB"></span>`LOCK_REQUIRES_INNODB` | `'Nested set and nested_sets_lock tables must use InnoDB; apply the lock migration ' . 'first.'` | Error when a MySQL nested set or registry table does not use InnoDB. |
| <span id="case-LOCK_REQUIRES_PHYSICAL_TABLE"></span>`LOCK_REQUIRES_PHYSICAL_TABLE` | `'Nested set locking requires a physical base table visible in the database ' . 'catalog.'` | Error when the nested set table is not a physical base table visible in the catalog. |
| <span id="case-LOCK_REQUIRES_SAVEPOINTS"></span>`LOCK_REQUIRES_SAVEPOINTS` | `'Nested set writer locking requires savepoint support; enable ' . '\'Connection::$enableSavepoint\'.'` | Error when savepoints are disabled on the connection. |
| <span id="case-LOCK_REQUIRES_SQLITE_MAIN_DATABASE"></span>`LOCK_REQUIRES_SQLITE_MAIN_DATABASE` | `'Nested set locking supports the SQLite main database only.'` | Error when a SQLite table is outside the `main` database. |
| <span id="case-LOCK_TIMEOUT_OUT_OF_RANGE"></span>`LOCK_TIMEOUT_OUT_OF_RANGE` | `"Nested set lockTimeout must be between '1' and '3600' seconds."` | Error when the lock timeout is outside the accepted range. |
| <span id="case-MODEL_NOT_ACTIVE_RECORD"></span>`MODEL_NOT_ACTIVE_RECORD` | `'Nested set queries require an ActiveRecord model.'` | Error when a nested set query model is not an ActiveRecord class. |
| <span id="case-NODE_MODIFIED"></span>`NODE_MODIFIED` | `'The nested set node has been modified by another request.'` | Error when a node optimistic lock version has changed. |
| <span id="case-NODE_NOT_FOUND"></span>`NODE_NOT_FOUND` | `'The nested set node no longer exists.'` | Error when a node no longer exists in storage. |
| <span id="case-PHYSICAL_TABLE_IDENTITY_MISSING"></span>`PHYSICAL_TABLE_IDENTITY_MISSING` | `'Missing physical table identity.'` | Error when the catalog row lacks the physical table identity. |
| <span id="case-PRIMARY_KEY_REQUIRED"></span>`PRIMARY_KEY_REQUIRED` | `"'%s' must have a primary key."` | Error when the owner model has no primary key for a specific class. |
| <span id="case-TABLE_NOT_FOUND"></span>`TABLE_NOT_FOUND` | `'The nested set table does not exist.'` | Error when the nested set table does not exist. |
| <span id="case-TARGET_STORAGE_MISMATCH"></span>`TARGET_STORAGE_MISMATCH` | `'The target node must use the same database connection and table.'` | Error when the target node uses another database connection or table. |
| <span id="case-TRANSACTION_REQUIRED"></span>`TRANSACTION_REQUIRED` | `"Nested set writes require a Yii database transaction. Configure 'transactions()' or " . 'begin an outer transaction.'` | Error when a write runs without an active Yii database transaction. |
| <span id="case-TREE_ATTRIBUTE_REQUIRED"></span>`TREE_ATTRIBUTE_REQUIRED` | `"Moving a subtree between trees requires 'treeAttribute'."` | Error when a subtree is moved between trees while `treeAttribute` is `false`. |
| <span id="case-UNSUPPORTED_OPERATION"></span>`UNSUPPORTED_OPERATION` | `"Unsupported operation: '%s'"` | Error when the pending operation does not move a node relative to a target. |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`getMessage()`](#method-getMessage) | Returns the formatted message string for the error case. | `Message` |

## Method details

### getMessage() <span id="method-getMessage"></span>

```php
public function getMessage(int|string ...$argument): string
```

Returns the formatted message string for the error case.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `...$argument` | `int\|string` | Values to insert into the message template. |

**Returns**

`string`: Formatted error message with interpolated arguments.