SignalR hub method, handling "incorrect parameters" exceptions #29171
Replies: 2 comments
-
Nope, these are most often development time errors and are likely uncommon in production.
If there is a parsing error then there wont be anything for you to validate, just a |
Beta Was this translation helpful? Give feedback.
-
"Validate" might be the wrong terminology. I am sorry for that. A simple case for me goes like this: I have a hub method that is used by both our own applications and customer's applications. When the method parameter is invalid, the client gets a generic message. This is not a development time exception for us, as we have a dynamic query model as a parameter to this hub method. I would like to return a more informative error message, for example, which part of the parameter object is erroneous. When using JsonSerializer, and parsing the parameter fails, server-side logs an error with debug level: Parameters to hub method 'methodName' are incorrect. I have two problems here:
I think the ability to override ErrorMessageHelper behaviour to send clients customized error messages would be great for my current case and many other cases. Current behaviour is set by "includeExceptionDetails" hub configuration. P.S. I am aware this might be a very specific issue, I am open to any suggestions/alternatives. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is it possible to catch a hub message parse error and take custom action? From what I gather, these exceptions do not reach any hub filters either.
The client gets an error message "Error: Failed to invoke 'hubMethod' due to an error on the server." when there is a parse error on MessagePack or JSON. There are many cases we want to validate the messages and return more meaningful error messages to the client.
Beta Was this translation helpful? Give feedback.
All reactions