| 
	
 | 
 Posted by Thomas Mlynarczyk on 07/10/12 11:32 
Also sprach Ian: 
 
> Thomas Mlynarczyk wrote: 
>> What I'm looking for is the best suited general return value for 
>> cases where an operation could not be successfully completed as 
>> expected and the function is not able to fix the error by itself and 
>> the error is of a nature where "drastic measures" like throwing an 
>> error or an exception would be inappropriate. 
 
> Isn't this situation precisely where exceptions are appropriate, 
> rather than 'drastic'.  They're certainly cleaner than any other 
> mechanism. 
 
Yes, but I meant a situation where an "error" can be handled easily by the 
calling function, like "Call function to get some data from a file, but if 
the specified file doesn't exist (function returns error), use some default 
instead." (The case of a function returning a default value was mentioned 
earlier in this thread, but assuming the function can be called for reading 
files in different contexts, each requiring its own "default values", then 
the function cannot return a default value as it doesn't know from which 
context it is called.) 
 
Greetings, 
Thomas
 
[Back to original message] 
 |