Skip to content

sdemirov/awt-error-formatter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

ErrorPayloadFormatter

Build Status Latest Version License

A PHP class for formatting error payloads in applications. This package provides a simple and consistent way to convert error information into a structured array format, making it easier to log, display, or broadcast errors throughout your application.

Table of Contents

Features

  • Consistent Error Formatting: Provides a custom format for error payloads.
  • Laravel Integration: Utilizes Illuminate\Http\Request for request data and accepts any Throwable instance for flexible error handling.
  • PSR-4 Autoloading: Easily integrates into your projects via Composer.
  • Robust Error Handling: Supports the latest PHP error handling best practices by using the Throwable interface.

Requirements

  • PHP 8.0 or later
  • Laravel (if integrating into a Laravel project)

Installation

You can install the package via Composer. Add the following line to your project's composer.json file:

composer require pensoft/awt-error-formatter

Usage

Include in your PHP class/file

use Pensoft\ErrorPayloadFormatter\ErrorPayloadFormatter;

Formatting error

// Format the error payload
$errorPayload = ErrorPayloadFormatter::format(
    Request $request,
    Throwable $e,
    'serviceName',
    'serviceId'
);
//send $errorPayload to third-party library or service

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages