PHPackages                             bytestechnolabs/custom-exception-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. bytestechnolabs/custom-exception-handler

ActiveLaravel-package[Logging &amp; Monitoring](/categories/logging)

bytestechnolabs/custom-exception-handler
========================================

Custom Exception Handler for Laravel

03PHP

Since Feb 22Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bhavik-bytescoder/package-laravel-custom-exception-handler)[ Packagist](https://packagist.org/packages/bytestechnolabs/custom-exception-handler)[ RSS](/packages/bytestechnolabs-custom-exception-handler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Certainly, here's a sample README file for your Laravel package, the Custom Exception Handler:

```
# Custom Exception Handler for Laravel

The **Custom Exception Handler for Laravel** is a package designed to provide custom exception handling within your Laravel application. It allows you to specify how different types of exceptions should be handled, set custom HTTP response codes, define error messages, and even provide custom data to be included in the response.

## Installation

You can easily install the package via Composer:

```shell
composer require bytestechnolabs/custom-exception-handler
```

Configuration
-------------

[](#configuration)

After installation, you can configure the Custom Exception Handler by publishing the configuration file. This file enables you to define which exceptions to handle and how they should be handled.

To publish the configuration file, run the following command:

```
php artisan vendor:publish --provider="BytesTechnolabs\CustomExceptionHandler\CustomExceptionHandlerServiceProvider"
```

Usage
-----

[](#usage)

### Custom Exception Handling

[](#custom-exception-handling)

The Custom Exception Handler allows you to handle specific exceptions differently. You can customize:

- Error messages
- HTTP response codes
- Custom data to include in the response

Here is an example of how to handle a `CustomException`:

1. Add the exception class name to the configuration:

```
'exceptions' => [
    // ... Other exception classes
    'CustomException',
],
```

2. Set the desired error message, HTTP status code, and custom data for the `CustomException`:

```
'exceptions_messages' => [
    // ... Other exception messages
    'CustomException' => 'A custom exception occurred.',
],

'exceptions_status_codes' => [
    // ... Other exception status codes
    'CustomException' => 400,
],

'custom_data' => [
    'CustomException' => [
        'custom_key' => 'custom_data_key',
        'data' => ['custom' => 'data'],
    ],
],
```

### Dynamic Custom Data

[](#dynamic-custom-data)

You can also add custom data dynamically during exception handling by using the `CustomDataHelper` class provided by the package:

```
use BytesTechnolabs\CustomExceptionHandler\CustomDataHelper;

try {
    // Code that may throw an exception
} catch (\Exception $exception) {
    // Add custom data to the response
    CustomDataHelper::addCustomDataToConfig($exception, ['custom' => 'data'], 'custom_data_key');

    // Rethrow the Exception
    throw $exception;
}
```

Support and Issues
------------------

[](#support-and-issues)

If you encounter any issues or have questions about the **Custom Exception Handler for Laravel**, please [report them on GitHub](https://github.com/bytestechnolabs/custom-exception-handler/issues).

License
-------

[](#license)

This package is open-source software licensed under the [MIT License](https://github.com/bytestechnolabs/custom-exception-handler/blob/master/LICENSE).

Author
------

[](#author)

- [Bytes Technolab](mailto:bhavik@bytestechnolab.com)

Version
-------

[](#version)

The current version of the package is 1.6.0.

Changelog
---------

[](#changelog)

For release notes and changes, please refer to the [GitHub releases](https://github.com/bytestechnolabs/custom-exception-handler/releases).

We hope you find the **Custom Exception Handler for Laravel** useful. If you have any suggestions or improvements for this package, feel free to contribute to the project on GitHub.

```

You can copy and paste this README into your project's README.md file and make any necessary adjustments to reflect your package's specifics.

```

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7344554a164b013569f3bee47018263a151e61ee0e074919847662097dd1c2fa?d=identicon)[bhavik.shah](/maintainers/bhavik.shah)

---

Top Contributors

[![bhavik-bytescoder](https://avatars.githubusercontent.com/u/140697845?v=4)](https://github.com/bhavik-bytescoder "bhavik-bytescoder (1 commits)")[![dhananjay-choksi-bytestechnolab](https://avatars.githubusercontent.com/u/142580657?v=4)](https://github.com/dhananjay-choksi-bytestechnolab "dhananjay-choksi-bytestechnolab (1 commits)")

### Embed Badge

![Health badge](/badges/bytestechnolabs-custom-exception-handler/health.svg)

```
[![Health](https://phpackages.com/badges/bytestechnolabs-custom-exception-handler/health.svg)](https://phpackages.com/packages/bytestechnolabs-custom-exception-handler)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.1k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M137](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
