Joschi
Trying to understand proper error handling
Not too familiar with generation, because we work with blazor and just share our dtos.
I only used Kiota (a few years ago) and that doesn't really care about your defined errors. It will just throw exceptions on non success in any case.
160 replies
Trying to understand proper error handling
To me it sounds like you should give minimal apis with the REPR pattern a try. Like FastEndpoints. It also has strongly typed endpoint methods with union responses, which will end up in the OpenApi schema.
160 replies
Trying to understand proper error handling
Some people only have one endpoint in each controller class when using mvc.
It is often done to reduce the dependencies in each controller.
Regarding your problems above with exceptions and results.
The advantage of an Result implementation is, that you are forced to handle errors. And you are aware that errors could happen in a method.
Unless it is documented or you read the methods source, you cannot know if and which exceptions it may throw.
In APIs this will result in 500 responses, which is often undesired.
What we currently do is to map our different Error types to the corresponding api error. So a NotFoundError would return a 404.
Having it well documented in an OpenApi schema, without manually defining the possible errors that could happen at this specific endpoint is really hard. Probably even impossible in MVC. Mainly because everything is boiled down to IActionResult. And its hard to know at compile time which actual types could maybe occour.
But honestly not that important unless you develop an API meant for public consumption.
160 replies
do defined route added to the the routes table when the app.Run() executed or before?
Thats not the actual Pipeline. Thats just the registering of the pipeline.
The pipeline runs, when a http request comes in. And the program only runs after app.Run is called.
5 replies
When should one use a custom delegate instead of Func/Action/Predicate?
Multicast delegates is how events are implement in C# as far as I know.
Delegates are not that often used, but they are valuable if you go deeper into the functional style of C#.
https://www.youtube.com/watch?v=2TXvwUgaMHs&t=1s
122 replies
Manipulating Strings
The idea would be, that you have a full script, 300+ pages long.
Now you want to convert all the camera directions and positions into the case you prefer.
It's way faster writing code for you to do that.
What you got there is just the bases for doing it.
13 replies
Manipulating Strings
Strings in C# are immutable. Meaning you cannot change the actual string itself, just creating new ones.
So what you want to do is extract the parts you want to change, change them and then rebuild the full string.
You are more or less doing it, but I guess your input should be the original unmodified string. Without any
ToUpper
mixed in there like you did.
There are ways of doing this more efficient, but you should not worry about that right now.13 replies
Inheritance
Ok found the problem and it has nothing to do with inheritance.
Your
constructor
sets the value of the texture
property
, but your setter
sets its value to itself.
The setter
has to set the value of the backing field
(ltexture
) to value
.
While we are at it. You should adhere to the C# format standards. Properties
start with uppercase letters and fields
start lowercase and often even with a underscore.
And if you don't have a special reason for creating a backing field yourself you should use auto properties
.
19 replies