PHP Classes

Mezon REST Exception: Exception class to use in REST APIs applications

Recommend this page to a friend!
  Info   View files Documentation   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 64 All time: 10,370 This week: 571Up
Version License PHP version Categories
mezon-rest-exception 1.0.0MIT/X Consortium ...5HTTP, PHP 5, Language
Description 

Author

This package provides an exception class to use in REST APIs applications.

It extends the base PHP Exception class to take parameters with values about the current HTTP request in order to provide more context information about the conditions that may trigger an exception.

Besides the exception code and exception message that is expected by the base PHP Exception class, it can also take parameters for the HTTP status code, HTTP request body and request URL.

Innovation Award
PHP Programming Innovation award nominee
February 2021
Number 7
Exceptions are special kind of class that is useful to pass details of errors that may happen within an application.

Usually exception classes carry information about the errors that includes an error message and an error code that can be useful to help applications to treat the errors in a a more convenient way for its users.

This package extends the information that is usually stored in an exception class. It adds details like the HTTP status code, request body and request URL, which may be useful for instance to generate error logs for applications that implement APIs.

Manuel Lemos
Picture of Alexey Dodonov
  Performance   Level  
Name: Alexey Dodonov <contact>
Classes: 58 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 185254 in Russian Federation Russian Federation
Week rank: 52 Up2 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 13x

Documentation

REST Exception Build Status codecov

Installation

Just type

composer require mezon/rest-exception

Usage

To use this class is very simple thing:

throw(new \Mezon\Rest\Exception(
	"", // message of the exception, like in the standard Exception class
	-1, // code of the exception, like in the standard Exception class
	200, // HTTP code of the request
	"<p>Warning!" // HTTP request body
));

  Files folder image Files  
File Role Description
Files folder imageTests (1 file)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file Exception.php Class Class source
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  Tests  
File Role Description
  Plain text file RestExceptionUnitTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:64
This week:0
All time:10,370
This week:571Up