Method chaining and exceptions in C#
- by devoured elysium
If I have a method chain like the following:
var abc = new ABC();
abc.method1()
.method2()
.methodThrowsException()
.method3()
;
assuming I've defined method1(), method2() and method3() as
public ABC method1() {
return this;
}
and methodThrowsException() as
public ABC method3() {
throw new ArgumentException();
}
When running the code, is it possible to know which specific line of code has thrown the Exception, or will it just consider all the method chaining as just one line? I've done a simple test and it seems it considers them all as just one line but Method Chaining says
Putting methods on separate lines also
makes debugging easier as error
messages and debugger control is
usually on a line by line basis.
Am I missing something, or does that just not apply to C#?
Thanks