Throw, the only .NET guard clause library you need

  Рет қаралды 13,739

Amichai Mantinband

Amichai Mantinband

Күн бұрын

Пікірлер: 42
@MilanJovanovicTech
@MilanJovanovicTech 2 жыл бұрын
Other than being a great library for throwing exceptions, this video is also a great showcase for how to implement the Guided Builder pattern. Notice how each method call in the fluent API has only the allowed methods that can be chained. And how you can go back to the top of the chain by calling the base method (Throw) again. Great video :)
@amantinband
@amantinband 2 жыл бұрын
Thanks man 🫶🏼
@marekjaskua6774
@marekjaskua6774 2 жыл бұрын
Package looks impresive. However, it would be nice if you add more support for custom exceptions. For instance a possibility to write user.ThrowIfNull("Unauthorized user"); Instead of user.ThrowIfNull(() => throw new ForbidException("Unauthorized user")); Writing my own such extension method each time would a bit of a pain.
@damianjoel5833
@damianjoel5833 3 ай бұрын
Agree, or something like that: UserName = userName.Throw().NotNull().NotEmpty().MaxLength(90);
@geraldmaale
@geraldmaale Жыл бұрын
I have actually learned a lot from your presentations. I integrated the ErrorOr package in my applications, and its wonderful. I even customized it with OpenTelemetry to add logs with codes as you demonstrated in your video. Thanks for works. 👍👍👍
@zhh174
@zhh174 2 жыл бұрын
I really loved your package ErrorOr so much.
@jvetter713
@jvetter713 Жыл бұрын
This is fantastic! Can't wait to give it a try.
@propro8040
@propro8040 Жыл бұрын
thank you. this is sooo cool. You are going to be the next Nick Chapsas
@OrgesKreka
@OrgesKreka Жыл бұрын
Great library and great explenation. Thank you. Please could you do a video on standart way to document a class/method.
@hamedsalameh8155
@hamedsalameh8155 2 жыл бұрын
Thanks for sharing this !! I'm gonna give this one a try !
@gui.ferreira
@gui.ferreira 2 жыл бұрын
Excellent video Amichai! Now I have to play with it. Already looking for an oportunity 😄
@amantinband
@amantinband 2 жыл бұрын
Thanks, waiting to hear what you think! 🫶
@birukayalew3862
@birukayalew3862 2 жыл бұрын
Dear Amichai, you have written a wonderful library and the presentation is excellent. keep going. The BuberDinner series project is complete or not. I am following you please finish it quickly.
@amantinband
@amantinband 2 жыл бұрын
Thanks, Biruk! Buber Dinner is not finished. There is a lot of DDD content still to come, don't worry!
@carloswinstonjavierllenas3117
@carloswinstonjavierllenas3117 Жыл бұрын
Hmmm, interesting and very readable. What I'm not seeing is what is the difference, for example in BuberDiner, with the HandlerValidators. Or are these used in other sections of that project? Basically I can't get if this complements the HandlerValidators or is another option entirely. Maybe I'm too stubborn with the old ways. :D
@robbyscherpereel
@robbyscherpereel 2 жыл бұрын
What about not throwing exceptions in your code. As exceptions are heavy.. Would rather work with FluentResult. Also you could use FluentValidation, which would make the config centralized. Thoughts?
@amantinband
@amantinband 2 жыл бұрын
Definitely the approach I prefer. If you like that approach, you might like my ErrorOr package: github.com/amantinband/error-or
@neutronstar482
@neutronstar482 2 жыл бұрын
Very usefull. Im going to replace some code in one project.
@kgnet8831
@kgnet8831 2 жыл бұрын
Great library 👍 but devils advocat, why not just use Fluentvalidation, why should I use Throw instead of? I see the appeal of this library, but it would be nice to have a comparison to FluentValidation and when to use which... either way after ErrorOr the second of your libraries I will put in my code, so thank you 👏
@amantinband
@amantinband 2 жыл бұрын
Thanks, Kai. FluentValidation is for model validation, whereas Throw is primarily for guard clauses
@bobek8030
@bobek8030 2 жыл бұрын
@@amantinband What if I dont want to throw exceptions, can I somehow use FluentResults with this package?
@ezecel9
@ezecel9 2 жыл бұрын
Great video, thanks
@a-s733
@a-s733 Жыл бұрын
amazing
@manaralkammessy6360
@manaralkammessy6360 2 жыл бұрын
Thanks Amichai for another fantastic tutorial. quick question how do we optimally use throw package with error/exeception hnadling middleware. do we throw our custom exceptions and validate it in the class the exception is thrown or is validation performed in the exception handling controller?
@amantinband
@amantinband 2 жыл бұрын
Ironically, I'm not a fan of throwing exceptions for flow control. Have you watched my video on flow control? I cover various approaches as well as what I would recommend: kzbin.info/www/bejne/qoubmHqnntaSf7c
@mugilkarthikeyan7131
@mugilkarthikeyan7131 2 жыл бұрын
The way I uses is that the model validation is done with ErrorOr and the data validation is done with Throw.
@DerClaudius
@DerClaudius 2 жыл бұрын
Bigger font would be nice.. so it's easier to view on mobiles
@guuggle8116
@guuggle8116 2 жыл бұрын
Which extension are you using to make vscode auto adding using statements when you use a type from say another referenced project? I've downloaded c# auto using extension but it seems to not be working when the type is from my own code base from another project.
@tussle2k
@tussle2k Жыл бұрын
I think it comes from GitHub copilot but I'm not 100% sure about that
@behype6527
@behype6527 Жыл бұрын
Hi Amichai and thanks for the content, i'm a Senior Java Engineer but you post high quality stuff that does crossover. By any chance, can you hint me towards a similar Java library?
@efimov90
@efimov90 2 жыл бұрын
15:08 So Validatable is a monad?
@amantinband
@amantinband 2 жыл бұрын
It's more of a wrapper around the value with some extra details. Are you asking with regards to the ExceptionCustomizations discriminated union?
@efimov90
@efimov90 2 жыл бұрын
@@amantinband but, isn't monad pattern about wrapping and adding some logick in processing? Oh... I see discriminated union one time, not so familiar with it. I'm about monad itself, i see several artiles that describes it like a way to use some logick behind scenes like logging while calcilating numbers (used like example in article). So i think this type and logick binded to it can be way to implement a monad and so as i see you more qualified in this topic than me i just try to ask about it.
@JinnGuild
@JinnGuild Жыл бұрын
​ @Sergey Efimov That is not what a Monad is. However, a "Maybe Monad" is a Monad that also has details. Since a lot of OO Developers have only touched on the "Maybe Monad", they mistake the pattern for a "Monad". It does look a lot like a "Result Type", but is semantically different. A Monad (in C#) is essentially just an IEnumerable that represents a Scalar (single value), and the collection either has ONE value of type T, or ZERO values of type T. Therefore, it is "Monadic" aka: It has One (or zero) values. Even though technically an IEnumerable (or some collection) could have millions. One value means the work was completed successfully and returned something. Zero values means there was some issue. This saves you from having to return `null` or `throw` an exception to represent that something went wrong. The "Maybe" Monad is the same as a Monad, but it also includes additional details about why ZERO items were returned. Exception info or just message or whatever. But this should not be used as or confused for a SOAP-style "Result" type. TLDR; The point of following Monadic methods is to NOT throw exceptions or return null. The whole point of this video is to purposely throw exceptions. Check out my related video: kzbin.info/www/bejne/jHTCpXShj85kiJY
@semenkovalev4988
@semenkovalev4988 Жыл бұрын
This is very nice lib for code writing/reading. But it looks like a performance killer and a possible memory eater. It creates structures in memory BEFORE using them. And in most cases it will be dummies.
@benjamininkorea7016
@benjamininkorea7016 Жыл бұрын
Bro, why do I have the overwhelming desire to ask for your advice about women? :D Just joking, ty for the great video. Subbed and keep it up
@urbanelemental3308
@urbanelemental3308 2 жыл бұрын
Applause!
@iliyan-kulishev
@iliyan-kulishev 2 жыл бұрын
Oh no I have refactored my whole project to use ErrorOr what is this now? :D
@amantinband
@amantinband 2 жыл бұрын
🤣
@eatsleepcode53
@eatsleepcode53 2 жыл бұрын
does microsoft use it ?
@allanhouston22
@allanhouston22 5 ай бұрын
It sucks. We shouldnt be throwing exceptions on validation
@stevekeith9507
@stevekeith9507 Жыл бұрын
This is awasome library, after watching all the features. I like OnlyInDebug()!
CRUD REST API in 1 Hour using .NET 6
1:05:57
Amichai Mantinband
Рет қаралды 23 М.
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 261 М.
Family Love #funny #sigma
00:16
CRAZY GREAPA
Рет қаралды 36 МЛН
Каха и лужа  #непосредственнокаха
00:15
КОГДА К БАТЕ ПРИШЕЛ ДРУГ😂#shorts
00:59
BATEK_OFFICIAL
Рет қаралды 7 МЛН
1, 2, 3, 4, 5, 6, 7, 8, 9 🙈⚽️
00:46
Celine Dept
Рет қаралды 56 МЛН
Making My Own Programming Language and Coding a Game in It
10:19
AstroSam
Рет қаралды 1,3 МЛН
Stop Using FirstOrDefault in .NET! | Code Cop #021
12:54
Nick Chapsas
Рет қаралды 90 М.
The Guard Clause in C# using the Throw NuGet Package
35:40
IAmTimCorey
Рет қаралды 21 М.
Stop Calling Your API a "REST API"
17:42
Amichai Mantinband
Рет қаралды 17 М.
C# Async Await Mistakes | Part 1
10:19
Amichai Mantinband
Рет қаралды 36 М.
How Guard Clauses Can Make Your Code Better
13:54
Milan Jovanović
Рет қаралды 13 М.
DON'T buy a Screen Protector before watching this.
10:50
Mrwhosetheboss
Рет қаралды 10 МЛН
Make the .NET CLI Your Best Friend | .NET & C# Essentials
19:41
Amichai Mantinband
Рет қаралды 16 М.
Family Love #funny #sigma
00:16
CRAZY GREAPA
Рет қаралды 36 МЛН