MessageError
extends Message
in package
MessageError class.
Represents a message error object as defined in the Agentic Commerce Protocol. This class handles message-level errors with type, code, content_type, content, and optional param.
Table of Contents
- $content : string
- Error content/message.
- $content_type : string
- Content type for the error message.
- $param : string|null
- RFC 9535 JSONPath to the problematic parameter (optional).
- $code : string
- Error code from ErrorCode enum.
- $type : string
- The error type (always 'error' for message errors).
- __construct() : mixed
- Constructor.
- invalid() : MessageError
- Create an invalid field error.
- is_error() : bool
- Check if the message is an error.
- missing() : MessageError
- Create a missing field error.
- out_of_stock() : MessageError
- Create an out of stock error.
- payment_declined() : MessageError
- Create a payment declined error.
- requires_3ds() : MessageError
- Create a requires 3DS error.
- requires_sign_in() : MessageError
- Create a requires sign in error.
- to_array() : array<string|int, mixed>
- Convert the error to an array.
- use_markdown() : mixed
- Use markdown content type for the content of the error.
Properties
$content
Error content/message.
protected
string
$content
$content_type
Content type for the error message.
protected
string
$content_type
= AutomatticWooCommerceInternalAgenticEnumsSpecsMessageContentType::PLAIN
Defaults to plain, but could also be markdown.
$param
RFC 9535 JSONPath to the problematic parameter (optional).
protected
string|null
$param
$code
Error code from ErrorCode enum.
private
string
$code
$type
The error type (always 'error' for message errors).
private
string
$type
= AutomatticWooCommerceInternalAgenticEnumsSpecsMessageType::ERROR
Methods
__construct()
Constructor.
public
__construct(string $code, string $content[, string|null $param = null ]) : mixed
Parameters
- $code : string
-
Error code from ErrorCode enum.
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
mixed —invalid()
Create an invalid field error.
public
static invalid(string $content[, string|null $param = null ]) : MessageError
Parameters
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
MessageError —is_error()
Check if the message is an error.
public
is_error() : bool
Return values
bool — True if the message is an error, false otherwise.missing()
Create a missing field error.
public
static missing(string $content[, string|null $param = null ]) : MessageError
Parameters
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
MessageError —out_of_stock()
Create an out of stock error.
public
static out_of_stock(string $content[, string|null $param = null ]) : MessageError
Parameters
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
MessageError —payment_declined()
Create a payment declined error.
public
static payment_declined(string $content[, string|null $param = null ]) : MessageError
Parameters
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
MessageError —requires_3ds()
Create a requires 3DS error.
public
static requires_3ds(string $content[, string|null $param = null ]) : MessageError
Parameters
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
MessageError —requires_sign_in()
Create a requires sign in error.
public
static requires_sign_in(string $content[, string|null $param = null ]) : MessageError
Parameters
- $content : string
-
Error content/message.
- $param : string|null = null
-
RFC 9535 JSONPath (optional).
Return values
MessageError —to_array()
Convert the error to an array.
public
to_array() : array<string|int, mixed>
Return values
array<string|int, mixed> — A message for the `messages` array of the response.use_markdown()
Use markdown content type for the content of the error.
public
use_markdown() : mixed
