▲ 342 ▼ What are your programming hot takes? (lemmy.ml) submitted 3 years ago by 257m@lemmy.ml to c/programming@programming.dev 894 comments fedilink hide all child comments
[–] argv_minus_one@beehaw.org 1 point 3 years ago (1 child) A string being parsed as a date-time is presumably user input, which is potentially invalid. permalink fedilink source parent hideshow 2 child comments replies: [–] Olissipo@programming.dev 1 point 3 years ago (1 child) When you say user, you mean a user of a function? In that case PHP would throw a TypeError, and presumably only happens when developing/testing. If you mean in production, like when submitting a form, an Exception may be thrown. In which case you catch it and return some error message to the user saying the date string is invalid. permalink fedilink source parent hideshow 2 child comments replies: [–] argv_minus_one@beehaw.org 1 point 3 years ago (1 child) By “user” I mean the person who is using the application. Using exceptions for handling unexceptional errors (like invalid user input) is a footgun. You don't know when one might be raised, nor what type it will have, so you can easily forget to catch it and handle it properly, and then your app crashes. permalink fedilink source parent hideshow 2 child comments replies: [–] Olissipo@programming.dev 1 point 3 years ago you can easily forget to catch it and handle it properly Even if I coded the form by hand and that happened, it's on me, not on the programming language. But I don't, I use a framework which handles all that boilerplate validation for me. permalink fedilink source parent
[–] Olissipo@programming.dev 1 point 3 years ago (1 child) When you say user, you mean a user of a function? In that case PHP would throw a TypeError, and presumably only happens when developing/testing. If you mean in production, like when submitting a form, an Exception may be thrown. In which case you catch it and return some error message to the user saying the date string is invalid. permalink fedilink source parent hideshow 2 child comments replies: [–] argv_minus_one@beehaw.org 1 point 3 years ago (1 child) By “user” I mean the person who is using the application. Using exceptions for handling unexceptional errors (like invalid user input) is a footgun. You don't know when one might be raised, nor what type it will have, so you can easily forget to catch it and handle it properly, and then your app crashes. permalink fedilink source parent hideshow 2 child comments replies: [–] Olissipo@programming.dev 1 point 3 years ago you can easily forget to catch it and handle it properly Even if I coded the form by hand and that happened, it's on me, not on the programming language. But I don't, I use a framework which handles all that boilerplate validation for me. permalink fedilink source parent
[–] argv_minus_one@beehaw.org 1 point 3 years ago (1 child) By “user” I mean the person who is using the application. Using exceptions for handling unexceptional errors (like invalid user input) is a footgun. You don't know when one might be raised, nor what type it will have, so you can easily forget to catch it and handle it properly, and then your app crashes. permalink fedilink source parent hideshow 2 child comments replies: [–] Olissipo@programming.dev 1 point 3 years ago you can easily forget to catch it and handle it properly Even if I coded the form by hand and that happened, it's on me, not on the programming language. But I don't, I use a framework which handles all that boilerplate validation for me. permalink fedilink source parent
[–] Olissipo@programming.dev 1 point 3 years ago you can easily forget to catch it and handle it properly Even if I coded the form by hand and that happened, it's on me, not on the programming language. But I don't, I use a framework which handles all that boilerplate validation for me. permalink fedilink source parent