All language subtitles for 004 An Overview of Error Handling_Downloadly.ir_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So, up until this point in the course

we haven't really handled errors

in a good way or in a central place in our application.

What we did was to simply send back

an error message as JSON in each route handler

in case something went wrong.

Right?

So that's basically what we're gonna fix in this section.

But for now, let's take a minute

to just get a brief overview of error handling in Express.

And we start by actually distinguishing

between two types of errors that can occur.

Operational errors and programming errors.

So, operational errors are problems

that we can predict will inevitably happen

at some point in the future.

And so we just need to handle them in advance.

They have nothing to do with bugs in our code.

Instead, they depend on the user, or the system,

or the network.

So, things like a user accessing an invalid route,

inputting invalid data, or an application failing to connect

to the database.

All these are operational errors

that we will need to handle in order

to prepare our application for these cases.

You will also see the term, "exception"

being used instead of error

and while they are conceptually different,

many people use the terms error

and exception interchangeably.

And I'm just gonna call them, "errors,"

in this course as well in order to avoid confusion.

Anyway, on the other hand, we have programming errors.

Which are simply bugs that we developers

introduce into our code.

Like, for example, trying to read properties

from an undefined variable, using await without async,

accidentally using request.query instead of request.body,

or many other errors, really, that we might make.

So, you know how it works, right?

And they are really inevitable

but also more difficult to find and to handle.

Okay, so, it's important that you understand

this crucial difference between operational errors

and programming errors.

So, when we're talking about error handling with Express,

we mainly just mean operational errors.

Because these are the ones that are easy

to catch and to handle with our Express application.

And Express actually comes with error handling

out of the box.

So, all we have to do is to write

a global express error handling middleware

which will then catch errors coming

from all over the application.

So, no matter if it's an error coming from a route handler,

or a model validator or really, someplace else,

the goal is that all these errors end up

in one central error handling middleware.

So that we can send a nice response back to the client

letting them know what happened.

And so, really, handling in this case just means

sending a response letting the user know what happened.

But handling can also mean, in other cases,

retrying the operation or crashing the server,

or just ignoring the error altogether.

Sometimes, that's just the best option.

Now the beauty of having a global error handling middleware

is that it allows for a nice separation of concerns.

So, we don't have to worry about error handling

right in our business logic or our controllers,

or really anywhere in our application.

We can simply send the errors down to the error handler

which will then decide what to do with them next.

All right?

So, with all that being said,

let's now actually start implementing this.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.