PHPackages                             ohansyah/laravel-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. ohansyah/laravel-exception-handler

ActiveLibrary

ohansyah/laravel-exception-handler
==================================

Laravel API Exception Handler with readable error messages

0.1.20(2y ago)0180MITPHPPHP ^7|^8

Since Mar 1Pushed 2y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (5)Used By (0)

Laravel Exception Handler
=========================

[](#laravel-exception-handler)

[![Latest Version](https://camo.githubusercontent.com/a806bf37121e1eeb76cdfb59ba35feb66a85b559b3b07d86c086867b76ee53c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f68616e737961682f6c61726176656c2d657863657074696f6e2d68616e646c65722e737667)](https://packagist.org/packages/ohansyah/laravel-exception-handler) [![Total Downloads](https://camo.githubusercontent.com/87d0573d176c0853817d28127c9d29230864e4a9bf3164aa229b6914fd1e844d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f68616e737961682f6c61726176656c2d657863657074696f6e2d68616e646c65722e737667)](https://packagist.org/packages/ohansyah/laravel-exception-handler) [![License](https://camo.githubusercontent.com/d896c26b4f0c5cb54c0f27e4124fd168e5f54319984799447251e95130e20d37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6f68616e737961682f6c61726176656c2d657863657074696f6e2d68616e646c65722e737667)](https://packagist.org/packages/ohansyah/laravel-exception-handler)

Introduction
------------

[](#introduction)

Laravel API Exception Handler with readable error messages. However, this package is specifically designed to be compatible with older PHP versions and Laravel or Lumen legacy projects.

Installation
------------

[](#installation)

```
composer require ohansyah/laravel-exception-handler

```

#### Register Service Provider

[](#register-service-provider)

```
$app->register(Ohansyah\ExceptionHandler\ExceptionHandlerServiceProvider::class);

```

#### Register Config

[](#register-config)

```
$app->configure('exception-handler');

```

#### Refreshing

[](#refreshing)

```
composer dump-autoload

```

#### Publish Config and Lang

[](#publish-config-and-lang)

```
php artisan exception-handler:publish

```

Usage
-----

[](#usage)

use the Traits and simpy using available method resException(), resError(), resSuccess()

```
use Ohansyah\ExceptionHandler\Traits\ResponseTransform;

class Name
{
    use ResponseTransform;
    ...
    resException(Exception $exception);
    resError($responseMessage, int $responseCode = 400, array $additionals = []);
    resSuccess($responseMessage, int $responseCode = 200);
    resThrowable(Throwable $throwable);
}

```

#### Global Exception Handler

[](#global-exception-handler)

```
// app\Exceptions\Handler.php
if (!($exception instanceof ValidationException) && !($exception instanceof NotFoundHttpException)) {
    return $this->resException($exception);
}

```

#### Sample Usage

[](#sample-usage)

```
Request:
GET {{your-base-url}}/exception-handler/error?code=500

Response:
{
    "status": "error",
    "message": "Kami telah menerima laporan bahwa layanan ini sedang mengalami gangguan. Mohon maaf atas ketidaknyamanannya dan mohon menunggu sebentar.",
    "errors": {
        "message": [
            "Kami telah menerima laporan bahwa layanan ini sedang mengalami gangguan. Mohon maaf atas ketidaknyamanannya dan mohon menunggu sebentar."
        ]
    },
    "title": "Ups!! Terjadi Kendala Teknis",
    "exception": null
}

```

#### Translation

[](#translation)

```
resources\lang\en\http.php
resources\lang\id\http.php

```

#### Config

[](#config)

```
// config\exception-handler.php

'trace_exception' => env('SERVICE_TRACE_EXCEPTION', true),

```

License
-------

[](#license)

The Laravel Exception Handler package is open-sourced software licensed under the [MIT License](LICENSE.md).

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~1 days

Total

4

Last Release

797d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/848f92b87eed294d148e88fb33734ff7273c63e602edc6512dfbaaa91cc776ca?d=identicon)[ohansyah](/maintainers/ohansyah)

---

Top Contributors

[![ohansyah](https://avatars.githubusercontent.com/u/43288867?v=4)](https://github.com/ohansyah "ohansyah (1 commits)")

---

Tags

api-responseexception-handlinglaravel-packagelumen-package

### Embed Badge

![Health badge](/badges/ohansyah-laravel-exception-handler/health.svg)

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

PHPackages © 2026

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