This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi guys, I'm working on updating our existing error code system to one that will work with our web tier and generate dynamic messages. Currently, all our LS errors are integer codes which are translated into the user's local langauge with our own web framework. I'm running into issues where I need to generate custom messages. I need something like the following.
"You must have an update rate less than {0}". Where my own code will generate the value for {0}. What I'd really like is a validation error with a string, and an object array for parameters than can be used in the string format for localizations. However, I seem to be a bit stuck.
I can't extend ValidationError because it's sealed, nor can I instanciate an instance of a ValidationError and add child errors for params as a workaround. How can I get customized errors into my Entities errors? Below is an example of what I'd like to do.
if(spider.UpdateRate > MaxUpdateRate){ spider.Errors.Add(MaxUpdateRate.Code, new object[]{MaxUpdateRate}); }
Which in the web tier would be merged to "You must have an update rate less than 2" if the value in MaxUpdateRate were 2.
Thanks, Todd |
|
|
This isn't possible at the moment. You'd need to compose the error message yourself, including all localisation, and call Errors.AddError(localisedMessage). A possible workaround that keeps the business tier reasonably decoupled from presentation considerations is for the presentation tier to provide a service that the business layer can call to format/localise messages, and to inject that service into the business layer using standard dependency injection techniques or a service locator. |
|