Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields | Protected Attributes
Exception Class Reference
Inheritance diagram for Exception:
LocalizedException

Public Member Functions

 __construct (Phrase $phrase, $code=0, $httpCode=self::HTTP_BAD_REQUEST, array $details=[], $name='', $errors=null, $stackTrace=null)
 
 getHttpCode ()
 
 getOriginator ()
 
 getDetails ()
 
 getName ()
 
 getErrors ()
 
 getStackTrace ()
 
- Public Member Functions inherited from LocalizedException
 __construct (Phrase $phrase, \Exception $cause=null, $code=0)
 
 getRawMessage ()
 
 getParameters ()
 
 getLogMessage ()
 

Data Fields

const HTTP_BAD_REQUEST = 400
 
const HTTP_UNAUTHORIZED = 401
 
const HTTP_FORBIDDEN = 403
 
const HTTP_NOT_FOUND = 404
 
const HTTP_METHOD_NOT_ALLOWED = 405
 
const HTTP_NOT_ACCEPTABLE = 406
 
const HTTP_INTERNAL_ERROR = 500
 
const FAULT_CODE_SENDER = 'Sender'
 
const FAULT_CODE_RECEIVER = 'Receiver'
 

Protected Attributes

 $_details
 
 $_httpCode
 
 $_name
 
 $_stackTrace
 
 $_errors
 
- Protected Attributes inherited from LocalizedException
 $phrase
 
 $logMessage
 

Detailed Description

Web API exception should not be used directly by any modules except for Magento_Webapi.

During web API requests, all exceptions are converted to this exception, which is then used for proper error response generation.

Definition at line 20 of file Exception.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Phrase  $phrase,
  $code = 0,
  $httpCode = self::HTTP_BAD_REQUEST,
array  $details = [],
  $name = '',
  $errors = null,
  $stackTrace = null 
)

Initialize exception with HTTP code.

Parameters
\Magento\Framework\Phrase$phrase
int$codeError code
int$httpCode
array$detailsAdditional exception details
string$nameException name

Only HTTP error codes are allowed. No success or redirect codes must be used.

Definition at line 95 of file Exception.php.

103  {
105  if ($httpCode < 400 || $httpCode > 599) {
106  throw new \InvalidArgumentException(sprintf('The specified HTTP code "%d" is invalid.', $httpCode));
107  }
108  parent::__construct($phrase, null, $code);
109  $this->code = $code;
110  $this->_httpCode = $httpCode;
111  $this->_details = $details;
112  $this->_name = $name;
113  $this->_errors = $errors;
114  $this->_stackTrace = $stackTrace;
115  }
$details
Definition: vault.phtml:10
$errors
Definition: overview.phtml:9
$code
Definition: info.phtml:12
if(!isset($_GET['name'])) $name
Definition: log.php:14

Member Function Documentation

◆ getDetails()

getDetails ( )

Retrieve exception details.

Returns
array

Definition at line 142 of file Exception.php.

143  {
144  return $this->_details;
145  }

◆ getErrors()

getErrors ( )

Retrieve list of errors.

Returns
null|\Magento\Framework\Exception\LocalizedException[]

Definition at line 162 of file Exception.php.

163  {
164  return $this->_errors;
165  }

◆ getHttpCode()

getHttpCode ( )

Retrieve current HTTP code.

Returns
int

Definition at line 122 of file Exception.php.

123  {
124  return $this->_httpCode;
125  }

◆ getName()

getName ( )

Retrieve exception name.

Returns
string

Definition at line 152 of file Exception.php.

153  {
154  return $this->_name;
155  }

◆ getOriginator()

getOriginator ( )

Identify exception originator: sender or receiver.

Returns
string

Definition at line 132 of file Exception.php.

◆ getStackTrace()

getStackTrace ( )

Retrieve stack trace string.

Returns
null|string

Definition at line 172 of file Exception.php.

173  {
174  return $this->_stackTrace;
175  }

Field Documentation

◆ $_details

$_details
protected

Definition at line 52 of file Exception.php.

◆ $_errors

$_errors
protected

Definition at line 80 of file Exception.php.

◆ $_httpCode

$_httpCode
protected

Definition at line 59 of file Exception.php.

◆ $_name

$_name
protected

Definition at line 66 of file Exception.php.

◆ $_stackTrace

$_stackTrace
protected

Definition at line 73 of file Exception.php.

◆ FAULT_CODE_RECEIVER

const FAULT_CODE_RECEIVER = 'Receiver'

Definition at line 45 of file Exception.php.

◆ FAULT_CODE_SENDER

const FAULT_CODE_SENDER = 'Sender'

#- #+ Fault codes that are used in SOAP faults.

Definition at line 44 of file Exception.php.

◆ HTTP_BAD_REQUEST

const HTTP_BAD_REQUEST = 400

#+ Error HTTP response codes.

Definition at line 25 of file Exception.php.

◆ HTTP_FORBIDDEN

const HTTP_FORBIDDEN = 403

Definition at line 29 of file Exception.php.

◆ HTTP_INTERNAL_ERROR

const HTTP_INTERNAL_ERROR = 500

Definition at line 37 of file Exception.php.

◆ HTTP_METHOD_NOT_ALLOWED

const HTTP_METHOD_NOT_ALLOWED = 405

Definition at line 33 of file Exception.php.

◆ HTTP_NOT_ACCEPTABLE

const HTTP_NOT_ACCEPTABLE = 406

Definition at line 35 of file Exception.php.

◆ HTTP_NOT_FOUND

const HTTP_NOT_FOUND = 404

Definition at line 31 of file Exception.php.

◆ HTTP_UNAUTHORIZED

const HTTP_UNAUTHORIZED = 401

Definition at line 27 of file Exception.php.


The documentation for this class was generated from the following file: