+ Fix bug with error message

This commit is contained in:
DJERY-TOM 2020-05-01 20:14:33 +01:00
parent e1df77862a
commit 17e39a5982
4 changed files with 18 additions and 5 deletions

View File

@ -3,6 +3,7 @@
namespace App\Exceptions;
use App\Traits\ApiResponser;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Auth\AuthenticationException;
@ -100,6 +101,18 @@ class Handler extends ExceptionHandler
return $this->errorResponse($exception->getMessage(),Response::HTTP_INTERNAL_SERVER_ERROR);
}
if ( $exception instanceof ClientException)
{
$message = $exception->getResponse()->getBody()->getContents();
$error =json_decode($message) ;
$code = $exception->getCode();
if($error)
return $this->errorResponse($error->error,$code);
else
return $this->errorResponse($message,$code);
}
if( env('APP_DEBUG', false))
{
return parent::render($request,$exception);

View File

@ -48,7 +48,7 @@ class CreditController extends Controller
$this->validate($request,$rules);
if($walletParrain->balance_princ < $request->montant)
return $this->errorResponse(trans('messages.princ_balance_inf_to_demand_amount') . 'modified',Response::HTTP_BAD_REQUEST);
return $this->errorResponse(trans('messages.princ_balance_inf_to_demand_amount'),Response::HTTP_BAD_REQUEST);
$walletAgent->balance_princ += $request->montant;
$walletParrain->balance_princ -= $request->montant;
@ -72,7 +72,7 @@ class CreditController extends Controller
// }catch (\Exception $e){
// echo "Error: " . $e->getMessage();
// }
return $this->successResponse(trans('messages.succes_treated_demand'));
return $this->successResponse(trans('messages.success_treated_demand'));
}
public function cancelDemand($id_demand ,Twilio $twilio){

View File

@ -3,7 +3,7 @@ return [
'empty_com_balance' => 'Commission balance is empty',
'treated_demand' => 'Credit request already processed',
'canceled_demand' => 'Canceled credit request',
'princ_balance_inf_to_demand_amount' => 'Your main balance is less than the amount of the request, do you want to change the amount?',
'princ_balance_inf_to_demand_amount' => 'Your main balance is less than the amount of the request, do you want to change the amount ?',
'new_wallet_added' => 'New wallet added',
'succes_treated_demand' => 'Request successfully processed'
'success_treated_demand' => 'Request successfully processed'
];

View File

@ -5,5 +5,5 @@ return [
'canceled_demand' => 'Demande de credit annulée',
'princ_balance_inf_to_demand_amount' => 'Votre solde principal est inférieur au montant de la demande, voulez vous modifier le montant ?',
'new_wallet_added' => 'Nouveau wallet ajouté',
'succes_treated_demand' => 'Demande traitée avec succès'
'success_treated_demand' => 'Demande traitée avec succès'
];