Ep19 - Laravel Exceptions | Laravel API Server

  Рет қаралды 7,925

Acadea.io

Acadea.io

Күн бұрын

Visit acadea.io/learn for more lessons and content!
Join my newsletter here to get the BEST updates: sendfox.com/ac...
Series playlist: • Laravel API Server fro...
Getting our API server to handle exceptions in our app is not a trivial task. Error messages must be consistent and helpful. Let's look at how can we handle exceptions in Laravel.
------------
Source code for this lesson:
github.com/aca...
Subscribe for more: / @acadeaio
Read unlimited Medium articles. Become a Medium member today: / membership
** Affiliated links
Earn passive income from crypto while you sleep! Get started on Nexo today! Up to 12% annual interest. Get $10 USD reward if you use my referral link below.
nexo.io/ref/2a...
Use the legendary Git GUI for FREE! You are seriously missing out if you are not using it.
Gitkraken: www.gitkraken....
Beautiful designs created instantly to wow your social networks!
Stencil: getstencil.com?tap_a=9103-1801f8&tap_s=595482-2f5817
A simple and scalable cloud hosting platform for all developer needs.
Digital Ocean: m.do.co/c/6ffb...
Get started on Crypto today. Gets 10% off of all crypto trading fee if you use my referral link below.
www.binance.co...
Outro Music:
Wayr -- Between Our Universes • 【Chillstep】Wayr - Betw...

Пікірлер: 9
@drewadorador6527
@drewadorador6527 3 жыл бұрын
Again, thank you very much explaining the small details, and snippets of helper functions. They are very helpful in coding with laravel.
@Acadeaio
@Acadeaio 3 жыл бұрын
You're very welcome Drew! Please share my videos around if you can. It will really help me out.
@amirhaditutorials2258
@amirhaditutorials2258 3 жыл бұрын
so great tutorials
@DevAmirull
@DevAmirull Жыл бұрын
U are awesome man. Great video, thank you so much.
@riza4329
@riza4329 2 жыл бұрын
Thanks so much
@rootdefault6263
@rootdefault6263 2 жыл бұрын
Great video much appreciated but i when i create my own exception class and at the render, function return a JSON object with a message saying failed I don't get that it returns a laravel view(the one you get when you start a new project). Laravel 8 project public function register(Request $request) { $request->validate([ 'name' => 'required', 'email' => 'required', 'password' => 'required', 'user_type' => 'required', 'village' => 'required', ]); try { $user = new User; $user->name = $request->name; $user->email = $request->email; $user->password = Hash::make($request->password); $user->user_type = $request->user_type; $user->village = $request->village; if ($user->user_type == 'farmer') { $user = new User; $user->name = $request->name; $user->email = $request->email; $user->password = Hash::make($request->password); $user->user_type = $request->user_type; $user->village = $request->village; if($user->save()){ return 'user success'; } $farmer = new Farmer; $farmer->farmer_id = $user->id; $farmer->region = $request->region; $farmer->crop_type = $request->crop_type; if($farmer->save()){ return 'farmer success'; } // throw when save failed if (!$user->save()) throw new UserNotSavedException('User creation fail'); } // throw when null if ($request == null) throw new NullException('Request is null'); }catch (UserNotSavedException $e) { return $e->render(); } catch (NullException $e) { return $e->render(); } ------------------------- my null exception class -------------------------
@volkankahraman_
@volkankahraman_ 3 жыл бұрын
Greate video but you don't need to create exception for just converting response to json. Laravel already doing that. All you have to do is add "Content-Type" "application/json" inside header
@Acadeaio
@Acadeaio 3 жыл бұрын
Good point, but the purpose of exception classes is to not just convert error to json, but also allow us to customise the HTTP error code and provide a consistent error response structure, plus error reporting.
@Fureszk
@Fureszk 2 жыл бұрын
You mean Accept: "application/json"
Ep20 - Events and Event Listeners | Laravel API Server
8:50
Acadea.io
Рет қаралды 3,3 М.
Ep12 - Laravel API Routes Best Practices
12:58
Acadea.io
Рет қаралды 8 М.
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 40 МЛН
Life hack 😂 Watermelon magic box! #shorts by Leisi Crazy
00:17
Leisi Crazy
Рет қаралды 80 МЛН
SISTER EXPOSED MY MAGIC @Whoispelagheya
00:45
MasomkaMagic
Рет қаралды 13 МЛН
НАШЛА ДЕНЬГИ🙀@VERONIKAborsch
00:38
МишАня
Рет қаралды 2,8 МЛН
Laravel: Avoid Try-Catch In Every Method (What To Do Instead)
4:45
Laravel Daily
Рет қаралды 33 М.
Laravel Exceptions in depth | Arabic
20:39
Mahmoud Anwar
Рет қаралды 1,5 М.
🔥 Using Custom Exceptions to write better, clearer code - Laravel
18:24
Ep21 - Sending Email | Laravel API Server
11:09
Acadea.io
Рет қаралды 4,7 М.
Обработка исключений | #24 - Курс по основам Laravel
9:14
Михаил Русаков
Рет қаралды 1,3 М.
Java Custom Exceptions Tutorial - It's Way Easier Than You Think
14:29
Coding with John
Рет қаралды 160 М.
The Exception Mistake You Must Never Make in C#
8:04
Nick Chapsas
Рет қаралды 44 М.
Standardised Responses with Laravel Responsables
15:49
Codecourse
Рет қаралды 2,3 М.
This mother's baby is too unreliable.
00:13
FUNNY XIAOTING 666
Рет қаралды 40 МЛН