Template:Computer Programming/Error Handling/2

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Our example make use of the fact that all valid return values for √ are positive and therefore -1 can be used as an error indicator. However this technique won't work when all possible return values are valid and no return value is available as error indicator.

Error (success) indicator parameter[edit source]

An error condition is returned via additional out parameter. Traditionally the indicator is either a boolean with "true = success" or an enumeration with the first element being "Ok" and other elements indicating various error conditions.