Hi all,
I have an ApplicationService action that may raise a warning based on some conditions, which must abort and undo the current UOW, then return a warning to the user. The user then confirm the warning and re-submit the same request (with a flag confirmed:true so the warning isn't raised again).
The simplest way is to throw an UserFriendlyException, but then on the client I need to distinguish Error and Warning. My first idea is to extend the ABP framework with a UserFriendlyWarningException that I could throw and I could serialized it in a different way than the UserFriendlyException.
But before going through this, I was wondering how do you guys would handle this and if there is something already built-in for warning/confirmation like that.
Thanks !
3 Answer(s)
-
0
Bump
-
0
Than can be possible. But you can also add "bool NeedsConfirmation" to your return DTO and set it if this is not confirmed. Also add a "IsConfirmed" to your input DTO to check the confirmation. Thus, you can do it without exceptions.
Also, UserFriendlyException has a "int Code" property which is 0 by default and can be used to return specific codes. Then you can handle it in the client.
-
0
Many thanks for the ideas.
I would like to add a "bool NeedsConfirmation" on my output DTO, but how can I undo the current UOW and still return a DTO ?
The only way I know is to throw and Exception, but then my DTO is not returned, it is the ABP builtin Exception filter that serialise the response.