lakshmaji/exceptions

Exception Handler for Laravel

1.0.0 2018-06-10 05:34 UTC

This package is auto-updated.

Last update: 2024-04-08 17:57:24 UTC


README

Install with composer

    composer require lakshmaji/exceptions

Service provider will be registered automatically

Publish translations

    php artisan vendor:publish 

Custom Exception class

<?php

namespace App;

use Lakshmaji\Exceptions\GenericExceptionType;


/**
 * -----------------------------------------------------------------------------
 *   CustomException for defining exception codes
 * -----------------------------------------------------------------------------
 * Class having methods to define error codes related to DB exceptions.
 *
 * @since    1.0.0
 * @version  1.0.0
 * @author   Lakshmaji 
 */
class CustomException extends GenericExceptionType
{
    // DUPLICATE RECORD
    /**
     * @var array
     */
    public static $DUPLICATE_RECORD = ['error_code' => 12000, 'code' => 400];
    
    // General Error
    /**
     * @var array
     */
    public static $GENERAL_ERROR = ['error_code' => 10001, 'code' => 400];

    
}
// end of class GenericExceptionType
// end of file GenericExceptionType.php

Usage

    // In controller
    throw new GenericException(CustomException::$DUPLICATE_ORGANIZATION);

License

MIT