-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Result.Error returns null instead of Result when returned from a method called from a controller #186
Comments
edit: previously thought it might be the latest vs that broke it, but tried again with older version and got the same error. Funnily enough, CriticalError also works, in that I get a Result back of that type. Error, however, always returns null! |
I just added this package to my project. In my first tests, I got a null error when I wanted to return the Error class. There are no problems with other return types. However, when returning with Error, a null result is returned to the person calling the method. |
I can confirm this. Trying to debug the issue, the result input parameter is null: But the problem is not only in EDIT: |
Fix issue with a new extension method
Fix issue with a new extension method
[celebrate] Josh Morales reacted to your message:
…________________________________
From: Steve Smith ***@***.***>
Sent: Saturday, May 25, 2024 5:17:38 PM
To: ardalis/Result ***@***.***>
Cc: Josh Morales ***@***.***>; Author ***@***.***>
Subject: Re: [ardalis/Result] Result.Error returns null instead of Result when returned from a method called from a controller (Issue #186)
Closed #186<#186> as completed via #189<#189>.
—
Reply to this email directly, view it on GitHub<#186 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAEKKBXSJCMKCX55YZFZ3V3ZEDBTFAVCNFSM6AAAAABIED6DM6VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJSHEZTGNJWGMYTCOI>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I'm having the weirdest issue, and I'm sure I'm probably just setting this up or using it wrong, but I can't figure out what that is.
I created a controller that I want to use to call a service that returns a result. If the result is successful, I get that result just fine. However if the service fails for whatever reason, and I attempt to return an error, that error result is null instead.
I created a super simple solution that mimics what I'm doing and does demonstrate the described behavior here: https://1drv.ms/u/s!Ahj4lgIVz2Ld6qwyH38Csz1FKpGY0g?e=p9Ac2D
It's just a controller with an injected service that returns one of the two results. The Success result works, but the Error result throws a null reference exception back in the calling controller because null is returned instead.
What am I doing wrong? this weirdly seems to work in other spots using razor pages, so I think maybe there's something wrong with my controller context or setup?
Any ideas? Much appreciated!!
The text was updated successfully, but these errors were encountered: