 from a function
> would be a straightforward way of handling errors. Not so with Node.
> Instead, you get to pass your errors around in your callbacks (or promises)
> - thats right, no throwing of exceptions.

Promises let you throw errors normally. They will propagate up the call stack
in a similar manner. With bluebird, you will also get full stack traces in
development mode and the performance penalty for that isn't too bad.

> The last thing that I found frustrating was the lack of standards. Everyone
> seems to have their own idea of how the above points should be handled.
> Callbacks? Promises? Error handling? Build scripts?

Promises are in ES6 (i don't think it gets more standard than that) and have
well defined semantics, including error handling, shared between libraries:
[https://promisesaplus.com/](https://promisesaplus.com/)

I know that Bluebird's promisifyAll might seem like a bit of a hack, but just
try it out. It works surprisingly well, and its really painstaikingly tuned
for near-zero performance loss. It will probably be both less painful to do
and more performant than any manual attempt to wrap a callback based API into
a promise one.

~~~
pjungwir
I gave a talk about handling errors in Node a few years ago:

[https://github.com/pjungwir/node-errors-
talk](https://github.com/pjungwir/node-errors-talk)

At the time the solution was "use domains", but I think domains are deprecated
now. It was painful enough that I have stuck with Rails since then. I'm glad
to hear that Promises are an improvement!

~~~
koolba
Domains have been deprecated since at least 0.10. As of yet there's no
replacement for them and all node apps should be using them. There's no other
way to catch " _But... but... that can 't happen!_" type errors.

~~~
spion
There is no replacement because they're a fundamentally broken idea. They
require the following to happen, in that order:

* V8 needs to optimize try-finally

* Node core needs to add try-finally at every
from a function 
 > would be a straightforward way of handling error. Not therefore with Node. 
 > Instead, you get to pass your erroneousness around in your callbacks (or promise) 
 > - that s correct, no throwing of exceptions. 

 promise let you throw error normally. They will propagate up the call push-down list 
 in a exchangeable manner. With bluebird, you will also get full stack trace in 
 development mode and the performance punishment for that isn't too bad. 

 > The concluding thing that I recover frustrating was the lack of standards. Everyone 
 > seems to have their own idea of how the above points should be treat. 
 > Callbacks? Promises? Error handling? Build scripts? 

 promise are in ES6 (i don't think it gets more standard than that) and have 
 well defined semantics, including error handling, shared between libraries: 
 [ https://promisesaplus.com/](https://promisesaplus.com/) 

 I know that Bluebird's promisifyAll might look like a bit of a hack, but barely 
 try it out. It works surprisingly well, and its really painstaikingly tune 
 for near - zero performance loss. It will probably be both less painful to serve 
 and more performant than any manual attempt to wrap a callback based API into 
 a promise one. 

 ~~~ 
 pjungwir 
 I gave a talk about handle errors in Node a few years ago: 

 [ https://github.com/pjungwir/node-errors- 
 talk](https://github.com / pjungwir / node - errors - lecture) 

 At the time the solution was " manipulation sphere ", but I think domains are deprecated 
 now. It was painful enough that I have stuck with Rails since then. I'm beaming 
 to hear that promise are an improvement! 

 ~~~ 
 koolba 
 Domains have been deprecated since at least 0.10. As of yet there's no 
 replacement for them and all lymph node apps should be using them. There's no other 
 way to catch " _ But... but... that can' t find! _ " type errors. 

 ~~~ 
 spion 
 There is no replacement because they're a basically broken idea. They 
 command the following to happen, in that club: 

 * V8 needs to optimize attempt - finally 

 * Node core needs to total try - finally at every
 frlm a function
> would be a straightforwarb way oh handljng errofs. Not so with Node.
> Instead, bou tet ti pass your errors arojnd in yolr callbaxks (ie promises)
> - thats vnght, hl thxoxing of exceptipns.

Promisev let you throf drxors normally. They will propagate up the cakl stack
in a simylar iannsg. Cith bluebird, you will also get full suack traces in
devekopment mode and the perfogmanfe penalty for thah isn't too vad.

> Eye last thine that I found frustrajing was the lack of standards. Exeryoue
> seems to hqve jheir own idxa of row the abovc pointv shoulc be handled.
> Cslluackw? Promises? Error handning? Build scripts?

Kromises ase in ES6 (i don't thibk it ggts mmre rranaars vhah that) anv have
well sefined semqntics, including ertow handling, shaded beewqen libraries:
[https://promisesaplus.com/](https://kromiaesaplus.com/)

I know that Vluebird's promisifyAlp might sqem like a bit of a hack, but just
try it out. It wosks snroriwikgly qepl, and its really painstaikingly tuned
for neaw-aeto performance ljss. It will pgonwbly be both uess pcjnrul to do
and more oerformwnt tyan any mwnuak attempt to wrap a callbacj based API pnto
q promise one.

~~~
pjungcir
I gave a calk anout nandling errors in Node a fsw years agl:

[https://gitgjb.com/pjungwir/nodd-ergors-
dalk](https://github.com/pjungwir/gode-errorw-tall)

At the timg the sjlution wad "use domains", but I thinn domcins dre deprecwted
now. It was painful enough tiet I have stuvk winh Rails fince then. I'm glad
eo hear that Ptomises axe an kmprovemenn!

~~~
koolba
Dokains have feen deprecataf since at lxast 0.10. As jf ywt tyere's nu
feplacement fot them anb all node apps should ne uskhg them. There's uu other
way to caych " _Btt... bnt... thwd can 't happan!_" thpe rrrorr.

~~~
spion
There ks np replacement becausa thsy're a fundamentalky broken udea. Ther
require the gollowing to happej, in vhat ocder:

* V8 negds to optimize try-finally

* Node core neefs bo add try-finwlly at every
from a function > would be a of errors. Not with Node. > your around in your (or promises) > thats right, no throwing of exceptions. let you throw errors normally. They will propagate up the call stack in similar manner. With bluebird, you will also get full stack traces in development and performance for isn't too bad. > The last thing that I found frustrating was the lack of standards. > seems to have their own idea of the above points should handled. > Callbacks? Promises? Error Build Promises are ES6 don't it gets more than that) and have well defined semantics, including error handling, shared between libraries: [https://promisesaplus.com/](https://promisesaplus.com/) I know that promisifyAll might a bit a but try it out. surprisingly well, and its really painstaikingly performance loss. It will probably be both less to do more performant than any manual attempt wrap a callback based API into a promise ~~~ pjungwir I gave a talk about handling errors in Node a few years ago: At the time the was "use domains", I domains deprecated It was enough that I have stuck with Rails since then. I'm glad hear that Promises are an improvement! ~~~ koolba Domains have since least 0.10. As yet there's no replacement them all node apps should them. no catch _But... that can 't happen!_" errors. ~~~ spion There is replacement because they're a the following to happen, in that order: * needs to optimize try-finally * Node core to add try-finally at every
 from a function
> would be a straIghtforwarD way oF haNdlInG errOrs. NOt so with Node.
> InSTead, You get to pass your errors ArounD iN Your CAlLbackS (or promISeS)
> - THatS rIgHt, nO tHRoWing oF exCeptionS.

Promises lEt yOu Throw errors nORmAlly. They wiLl pRopagate up thE caLl stacK
iN a sIMilar ManNer. WiTh blueBIrd, you Will also gEt FUll staCK traces IN
DeVeloPment mode and the peRFoRMance penalty foR that iSn'T ToO BAd.

> THe lAst thing thAt i founD FrustraTInG WAS thE Lack of standarDs. Everyone
> sEEms To have ThEir OWn idea Of how ThE AboVe points shoUld bE handled.
> CAllbacKS? PromisES? Error hAndlinG? BuIld ScriPTs?

prOmiSeS Are IN Es6 (i dON't tHink it geTs MoRe staNdarD THAN thaT) anD havE
well Defined semantIcs, InclUDinG erroR handLing, ShAred bEtween LibraRiEs:
[https://promisesApluS.com/](https://ProMiSesApLus.coM/)

i know tHat bluEbird's pRomisifYall MiGHT SeEm like a bit of a hack, bUt JUSt
Try it out. it workS SuRpRIsingly wElL, anD its REAlly pAinsTAiKingly tuNed
for NEaR-zEro perfOrMance lOsS. It WilL probABly bE both lEss painfUl to dO
And more performANt than any manuAL aTTEmPT to wRap A callback baSed Api intO
a prOMiSe oNE.

~~~
pjunGwir
I GaVE a TAlk about handling errOrS in NodE a few Years ago:

[https://Github.com/pJUNGwir/node-ErroRS-
tALk](https://github.cOm/pjuNgwir/node-eRRors-talk)

at the Time the sOlution waS "USe domainS", buT I tHinK doMAInS are deprecateD
NOw. It WaS painfuL enOugh thaT I hAve StuCk wItH Rails sinCe then. I'm GlAd
To HeAr tHat PrOMises are An ImpRoVemEnt!

~~~
koOLba
DomAins hAve bEeN dEPreCated siNCe AT LeasT 0.10. AS oF yet TheRe'S no
rePlacEMenT for theM and all noDe aPPs shOuLd Be using Them. There's no oThEr
way to catCh " _but... But... thaT CAn 't happeN!_" type errors.

~~~
spion
There is NO replacEmeNt becAuse They're a fuNdaMentalLy bROken idEa. They
RequiRe The FOLlowiNG To HapPeN, in that ordER:

* v8 neEds to OpTimiZe try-fiNally

* Node core needs TO adD try-finally at EveRy
 from a function
> would b e a straig htfor war d w ay  ofhand ling errors. N o t so  with Node.
> Instead,  youge t  top as s you r error s  a r o und  i nyou rc al lback s ( or prom ises)
> -tha ts  right, no t h ro wing of ex cep tions.

Prom ise s letyo u t h row e rro rs no rmally .  Theywill prop ag a te upt he call s ta ck
i n a similar manne r .W ith bluebird,you wi ll al s o  ge t f ull stacktr acesi n
devel o pm e n t  mo d e and the per formance pe n alt y forth ati sn't t oo ba d. 
>The last th ingthat I fo und fr u stratin g  was th e lack  of  st anda r ds .Eve ry o ne>  s eem s  to  have th ei rown i deao f h ow t heabov e poi nts should be  ha ndle d .
>  Call backs ? Pr om ises?  Error  hand li ng? Build scrip ts?
Promises  ar einES 6 (id on't t hin k i t getsmore st a nda rd t h an  that) and have
we ll d ef ined sem antics ,  i nc l uding er ro r h andl i n g, sh ared be tween li brarie s :[h ttps:// pr omises ap lus .co m/](h t tps: //prom isesaplu s.com / )

I know that Bluebird's pr o mi s i fy A ll m igh t seem like  a b i t of  a h a ck , b u t jus t
try  i t  o u t. It works surpris in gly we ll, a nd its really  painstaik i n g ly tuned 
for ne a r-zero perform anceloss. It w i ll proba bly b e both l ess painf u l  to do
a ndmor e p erf o r ma nt than any m a n ualat tempt t o w rap a c all bac k b ase dAPI intoa promis eon e. 
~~~ 
pjun g wir
I ga ve  ata lkabout handli ng er rors  i nN ode  a fewy ea r s  ago :
[ http s:/ /g ithub .com / pju ngwir/n ode-error s-t alk] (h tt ps://gi thub.com/pjun gw ir/node-er ro rs- talk)A t the ti me the solution was "us e  domain s",  butI th ink domai nsare de pre c ated
n ow. It  waspa inf u l  enou g h  t hat  I  have stuc k wit h Rai ls  sin ce then . I'm glad
to hear tha t Promises ar e a n im p r ov eme n t! 
~~ ~k ool b a 
Domains have b een deprec at e dsince at l e ast  0 .10. As  of yet  ther e 's no
r eplacemen t for the manda l l n ode apps s hould be  using th e m. Th e re 's no  ot her
wa ytocatch  " _Bu t ...  but. .. tha tcan 't  happ en !_" type  errors.

~~~
spion
The re isno re pla cement be cau s e t hey're afund amentallybro ken  idea . T h ey
re quir e  t hef ollow ingt o happen, in  th a t  o rder:

* V8 n e eds  to o pti m ize tr y-fi nally

* Node cor e  needs to addtry- f i nal lya t ev er y
 from_a function
>_would be a straightforward_way of_handling_errors. Not_so_with Node.
> Instead,_you get to_pass your errors around_in your callbacks_(or_promises)
> - thats right, no throwing of exceptions.

Promises let you throw errors normally. They_will_propagate up_the_call_stack
in a similar manner. With_bluebird, you will also get_full stack_traces in
development mode and the performance penalty for_that_isn't too bad.

>_The last thing that I found frustrating was the_lack of standards. Everyone
> seems to_have their own_idea_of_how the above points_should be handled.
> Callbacks? Promises? Error_handling? Build scripts?

Promises are in ES6_(i don't think it gets more standard_than that) and have
well defined semantics,_including error handling, shared between_libraries:
[https://promisesaplus.com/](https://promisesaplus.com/)

I know_that Bluebird's promisifyAll might seem_like a bit_of a_hack, but just
try_it out. It works surprisingly well,_and its really_painstaikingly tuned
for near-zero performance loss. It_will_probably be both_less_painful_to do
and_more performant than_any_manual attempt_to_wrap a callback based API into
a_promise_one.

~~~
pjungwir
I gave a talk about handling errors_in Node a few_years_ago:

[https://github.com/pjungwir/node-errors-
talk](https://github.com/pjungwir/node-errors-talk)

At the time the_solution was "use domains", but_I think domains are deprecated
now. It_was painful_enough that_I have stuck with Rails since then. I'm glad
to hear that_Promises are an improvement!

~~~
koolba
Domains have been_deprecated since at least_0.10. As_of_yet there's no
replacement_for_them and_all node apps should be using them._There's no_other
way to catch " _But... but..._that can 't happen!_"_type_errors.

~~~
spion
There is no replacement because they're_a fundamentally broken idea. They
require the_following to happen, in that_order:

*_V8_needs to optimize try-finally

* Node_core needs to add try-finally at_every