# elementor/3.35.0-dev2/modules/variables/services/batch-operations/batch-error-formatter.php

Elementor Website Builder – more than just a page builder, version 3.35.0-dev2. 47 lines.

- Page: https://pluginprobe.com/plugins/elementor/3.35.0-dev2/code/modules/variables/services/batch-operations/batch-error-formatter.php
- Raw: https://pluginprobe.com/plugins/elementor/3.35.0-dev2/raw/modules/variables/services/batch-operations/batch-error-formatter.php
- Modified: 2025-12-22T12:25:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/elementor/3.35.0-dev2/code/modules/variables/services/batch-operations/batch-error-formatter.php#L10-L20`.

```php
<?php

namespace Elementor\Modules\Variables\Services\Batch_Operations;

use Exception;
use Elementor\Modules\Variables\Storage\Exceptions\DuplicatedLabel;
use Elementor\Modules\Variables\Storage\Exceptions\RecordNotFound;
use Elementor\Modules\Variables\Storage\Exceptions\VariablesLimitReached;

class Batch_Error_Formatter {

	private const ERROR_MAP = [
		RecordNotFound::class => [
			'code' => 'variable_not_found',
			'status' => 404,
		],
		DuplicatedLabel::class => [
			'code' => 'duplicated_label',
			'status' => 400,
		],
		VariablesLimitReached::class => [
			'code' => 'invalid_variable_limit_reached',
			'status' => 400,
		],
	];

	public function status_for( Exception $e ): int {
		foreach ( self::ERROR_MAP as $class => $map ) {
			if ( $e instanceof $class ) {
				return $map['status'];
			}
		}

		return 500;
	}

	public function error_code_for( Exception $e ): string {
		foreach ( self::ERROR_MAP as $class => $map ) {
			if ( $e instanceof $class ) {
				return $map['code'];
			}
		}

		return 'unexpected_server_error';
	}
}

```
