Async Await try-catch hell

Async Await try-catch hell

Fireship

3 года назад

1,253,850 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Matthew C
Matthew C - 21.09.2023 07:45

.... monad

Ответить
-raf-
-raf- - 13.09.2023 15:22

today we discover lua multiple returns

Ответить
Novaz
Novaz - 11.09.2023 22:29

Big brain

Ответить
Blip👀
Blip👀 - 11.09.2023 09:22

Okay this is the most useful video i e watched today ❤

Ответить
Yousef Imran
Yousef Imran - 01.09.2023 21:52

Not a developer. Don't know JavaScript. But I a saw a short earlier about the same topic and the guy used Promise.allSettled() approach with a single try catch.

Ответить
M A D D Y
M A D D Y - 30.08.2023 18:30

Don’t use prettier

Ответить
Srijan
Srijan - 26.08.2023 04:11

Reactive programming introduction

Ответить
Uptime
Uptime - 04.08.2023 21:03

Literally Go, just switch to Go in this case.

Ответить
Benjamin Rast
Benjamin Rast - 31.07.2023 12:40

I recommended: await-to-js

Ответить
_ Milord _
_ Milord _ - 31.07.2023 05:50

Never have a bug in your code with one simple move: wrap the whole program in a try catch.

Ответить
Nyasha Chiroro
Nyasha Chiroro - 26.07.2023 20:35

Then people laugh a error handling in Go 😂😂😂

Ответить
Beyondo
Beyondo - 17.07.2023 14:40

Why don't you just wrap all await statements together with a single try-catch then handle accordingly by the caught error's type?

Ответить
Jose Marin
Jose Marin - 12.07.2023 17:32

Best solution to the problem is to use js-awe library

Ответить
Vorname Nachname
Vorname Nachname - 07.07.2023 09:09

Guys you all get trapped. He knows hes talking bs, but he knows a lot of us cant stand to not name and it as such and comment.

Ответить
GGorAA
GGorAA - 02.07.2023 04:56

Bro just invented the Result type

Ответить
Mica White
Mica White - 23.06.2023 09:25

How are the if statements better than the try/catch blocks?

Ответить
Fiks Anzo™
Fiks Anzo™ - 22.06.2023 19:34

That... Literally just moves the .Catch() somewhere else, forces you to use tuples and still requires you to process the errors if you need to return anything meaningful

Ответить
S A
S A - 20.06.2023 09:01

Either monad

Ответить
David Yoder
David Yoder - 17.06.2023 06:05

Or just use go.

Ответить
ImSamuka
ImSamuka - 11.06.2023 19:32

I forgot how bad try catch in java/typescript is, make me appreciate ".await?" in rust a thousand times more

Ответить
ian
ian - 10.06.2023 10:29

Just break promise functions out…

Ответить
Alexander D.
Alexander D. - 06.06.2023 15:44

There is no need to return array only to destructure it later. Just return Error and then use if (result instanceof Error) { ... } instead. If you need to handle some errors elssewhere then extend the Error type and use your custom types then. It's javascript, not a golang, no need to invent something not needed.

Ответить
marvin xulu
marvin xulu - 21.05.2023 16:22

wow

Ответить
Btotts
Btotts - 20.05.2023 20:07

You're basically just writing Go code then

Ответить
Louis Hong
Louis Hong - 19.05.2023 00:00

Rust.

Ответить
DaFrancc
DaFrancc - 17.05.2023 19:42

So you're telling me that it's basically Rust?

Ответить
Shapeless
Shapeless - 17.05.2023 16:34

Better a few try-catches one by one rather than nested...

Ответить
Ahmed_topujss
Ahmed_topujss - 15.05.2023 07:35

Just use express-async-handler < to not to write some many code.

Ответить
Azeek
Azeek - 11.05.2023 19:20

or do await Promise.all([promise1(), promise2()])

Ответить
Arlo Godfrey
Arlo Godfrey - 09.05.2023 01:29

Right, JS doesn't bubble up errors from functions. Would have made this a lot easier.

Ответить
Lenicon
Lenicon - 08.05.2023 20:06

I fuckin needed this holy shit. Tysm

Ответить
Lone Wolf Coding Professional
Lone Wolf Coding Professional - 20.04.2023 18:56

what about just use 1 await and all data is called in a callback function or function after success

Ответить
ence
ence - 19.04.2023 02:47

Or use Either from fp-ts

Ответить
Isi
Isi - 16.04.2023 11:03

Can't you put all awaits in one try catch

Ответить
Ihsan Mujdeci
Ihsan Mujdeci - 13.04.2023 12:45

This is golang style.

Ответить
Mekael Turner
Mekael Turner - 10.04.2023 12:47

It feels sort of like an Either monad. Awesome tip. Thanks

Ответить
Marcus Xu
Marcus Xu - 08.04.2023 09:44

Destructuring the tuple is not typescript-friendly, normally I would wrap data and error into an obj.

Ответить
CodingCouncil
CodingCouncil - 29.03.2023 16:07

Or called as the Either monad in FP convention

Ответить
Wayk123
Wayk123 - 29.03.2023 16:03

just use golang at this point

Ответить
Lucas Breitembach
Lucas Breitembach - 15.03.2023 02:03

this case Promise.all is better

Ответить
Dråfølin
Dråfølin - 12.03.2023 12:18

How to create rust from scratch:

Ответить
Abiira Nathan
Abiira Nathan - 12.03.2023 09:15

You just re-invented golang(go). if err !=null

Ответить
Sampath Sri Sitinamaluwa
Sampath Sri Sitinamaluwa - 07.03.2023 15:51

So, callbacks (with params (data, error)) to promises to async-await to error handling functions (that return [data, error], which we will then process with a pyramid of if-else's). How much time until we revert to callbacks?

Ответить
Mogus
Mogus - 05.03.2023 22:04

Bro even invented monad

Ответить
4cid-Andy
4cid-Andy - 28.02.2023 23:33

How to engineer js to golang

Ответить
Lex Flex
Lex Flex - 28.02.2023 07:15

Lets write golang in js

Ответить
Toesi chan
Toesi chan - 25.02.2023 13:48

Almost starts to look like elixir error handling

Ответить
noxabellus
noxabellus - 25.02.2023 05:43

i seriously do not understand why go style error handling has become so popular its objectively bug prone and inefficient

Ответить
Ousama
Ousama - 22.02.2023 23:07

A Monad?? Correct me if I am wrong.

Ответить
Lit Bro
Lit Bro - 21.02.2023 23:00

This is literally what Golang does lol

Ответить