Skip to content

Latest commit

 

History

History
43 lines (30 loc) · 1.86 KB

Unauthorized.md

File metadata and controls

43 lines (30 loc) · 1.86 KB

Class: Simpay\Exception\Unauthorized

This class extends the PHP built-in Exception class and represents an exception that is thrown when a HTTP 401 status code is returned from an API call.

Properties

  • private const MESSAGE = 'Unauthorized: %s'; : A constant string that represents the message format of the exception.

Constructor

private function __construct(string $message, \Throwable $previous = null)

Parameters

  • $message : A string that represents the error message.
  • $previous : An instance of \Throwable that represents the previous exception.

Return Value

  • None.

Exceptions thrown by the constructor

  • None.

Method Description

This constructor is private and is used to set the error message and status code of the Unauthorized exception. It takes in a string message and an optional Throwable object representing the previous exception. It calls the parent constructor of the Exception class and passes the formatted error message with the HTTP status code of 401 and the previous exception.

Method: create

public static function create(string $message, \Throwable $previous = null): self

Parameters

  • $message : A string that represents the error message.
  • $previous : An instance of \Throwable that represents the previous exception.

Return Value

  • An instance of self (i.e. an instance of Simpay\Exception\Unauthorized).

Exceptions thrown by the method

  • None.

Method Description

This method is a static factory method that is used to create and return an instance of the Unauthorized class. It takes in a string message and an optional Throwable object representing the previous exception. It then calls the private constructor of the class and passes the message and previous exception. It then returns a new instance of the Unauthorized class with the formatted error message.