CallMethod: Simple suggestion for more helpful error message.

CallMethod: Simple suggestion for more helpful error message.

Old forum URL: forums.lhotka.net/forums/t/8851.aspx


AnthonyV posted on Wednesday, April 28, 2010

I would like to suggest the following change to the thrown error in "Csla.Reflection.MethodCaller.CallMethod":

public static object CallMethod(object obj, string method, params object[] parameters)
public static object CallMethod(object obj, MethodInfo info, params object[] parameters)

From: throw new NotImplementedException(method + " " + Resources.MethodNotImplemented

To: throw new NotImplementedException(method + " " + Resources.MethodNotImplemented + " on " + obj.GetType().ToString());

The benefit is that the error messages gives a better clue to what is missing.

Thanks

 

RockfordLhotka replied on Wednesday, April 28, 2010

Something like this is a good idea. The word "on" is English though, so it can't be hard-coded into the output.

The real answer is for the MethodNotImplemented resource to be a string format mask - but that'd break all the international translations - and by break I mean throw an exception at runtime - so it is somewhat hard to do the right thing :(

AnthonyV replied on Thursday, April 29, 2010

Ouch, forgot that part. 

You could use something else to delimit the object type such as brackets.   That would be reasonably language independent and almost as readable.

To: throw new NotImplementedException(method + " " + Resources.MethodNotImplemented + " ( " + obj.GetType().ToString() + ")");

Anthony

Copyright (c) Marimer LLC