| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Modules\MCP\Support; |
| 4 |
|
| 5 |
defined('ABSPATH') || exit; |
| 6 |
|
| 7 |
/** |
| 8 |
* The closed set of machine-readable error codes the MCP tools return. |
| 9 |
* |
| 10 |
* Every MCPHelper::error() call uses one of these constants so the agent-facing |
| 11 |
* error contract lives in one place — auditable, typo-proof, and stable for a |
| 12 |
* client to branch on. Add a code here before using it. |
| 13 |
*/ |
| 14 |
class ErrorCodes |
| 15 |
{ |
| 16 |
const MISSING_IDENTIFIER = 'missing_identifier'; |
| 17 |
const MISSING_PARAM = 'missing_param'; |
| 18 |
const INVALID_PARAM = 'invalid_param'; |
| 19 |
const FORBIDDEN = 'forbidden'; |
| 20 |
const NOT_FOUND = 'not_found'; |
| 21 |
const CREATE_FAILED = 'create_failed'; |
| 22 |
const TOOL_FAILED = 'tool_failed'; |
| 23 |
const CONFIRMATION_REQUIRED = 'confirmation_required'; |
| 24 |
const CONFIRMATION_EXPIRED = 'confirmation_expired'; |
| 25 |
const CONFIRMATION_INVALID = 'confirmation_invalid'; |
| 26 |
const STATE_CHANGED = 'state_changed'; |
| 27 |
const LIMIT_EXCEEDED = 'limit_exceeded'; |
| 28 |
const UNFILTERED_HTML_REQUIRED = 'unfiltered_html_required'; |
| 29 |
const FEATURE_DISABLED = 'feature_disabled'; |
| 30 |
const CONCURRENT_REQUEST = 'concurrent_request'; |
| 31 |
const EXECUTION_UNKNOWN = 'execution_unknown'; |
| 32 |
|
| 33 |
/** Every declared code — used by tests to guard against undeclared codes. */ |
| 34 |
public static function all() |
| 35 |
{ |
| 36 |
return [ |
| 37 |
self::MISSING_IDENTIFIER, |
| 38 |
self::MISSING_PARAM, |
| 39 |
self::INVALID_PARAM, |
| 40 |
self::FORBIDDEN, |
| 41 |
self::NOT_FOUND, |
| 42 |
self::CREATE_FAILED, |
| 43 |
self::TOOL_FAILED, |
| 44 |
self::CONFIRMATION_REQUIRED, |
| 45 |
self::CONFIRMATION_EXPIRED, |
| 46 |
self::CONFIRMATION_INVALID, |
| 47 |
self::STATE_CHANGED, |
| 48 |
self::LIMIT_EXCEEDED, |
| 49 |
self::UNFILTERED_HTML_REQUIRED, |
| 50 |
self::FEATURE_DISABLED, |
| 51 |
self::CONCURRENT_REQUEST, |
| 52 |
self::EXECUTION_UNKNOWN, |
| 53 |
]; |
| 54 |
} |
| 55 |
} |
| 56 |
|