cm0002@lemmy.world to Programmer Humor@programming.dev · 2 years agoYes, But...lemmy.mlexternal-linkmessage-square78linkfedilinkarrow-up1766arrow-down19cross-posted to: [email protected]
arrow-up1757arrow-down1external-linkYes, But...lemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 2 years agomessage-square78linkfedilinkcross-posted to: [email protected]
minus-squarefuzzzerd@programming.devlinkfedilinkEnglisharrow-up21·2 years agoWhat about both? User supplies bad input? HTTP 400 with response body json describing the error in a standard format?
minus-squarebountygiver [any]@lemmy.mllinkfedilinkEnglisharrow-up7·2 years agowhen you are too lazy to ask your request library to not throw exception on non-200 responses.
minus-squaredan@upvote.aulinkfedilinkarrow-up5·2 years agoThrowing exceptions is fine since errors are an exceptional circumstance (not expected during normal use of the app), and you probably want errors to follow a different code path so that they can be logged, alerts triggered if needed, etc.
What about both? User supplies bad input? HTTP 400 with response body json describing the error in a standard format?
when you are too lazy to ask your request library to not throw exception on non-200 responses.
Throwing exceptions is fine since errors are an exceptional circumstance (not expected during normal use of the app), and you probably want errors to follow a different code path so that they can be logged, alerts triggered if needed, etc.