mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
fix documentation error
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27642 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
399e2f9b38
commit
c1aae0c84c
2 changed files with 20 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
2009-01-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Documentation/manual/ExceptionHandling.texi: Fix error in
|
||||
example of use of NS_VALUERETURN spotted by David Chisnall.
|
||||
|
||||
2009-01-20 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSKeyValueObserving.m: Automtically remove collected observers
|
||||
|
|
|
@ -86,16 +86,20 @@ For instance:
|
|||
@{
|
||||
FileHandle *handle = [self getFileHandle: filename];
|
||||
parse = [parser parseFile: handle];
|
||||
if (parse == nil)
|
||||
@{
|
||||
NS_VALUERETURN(nil);
|
||||
@}
|
||||
@}
|
||||
NS_HANDLER
|
||||
@{
|
||||
if ([[localException name] isEqualToString: MyFileNotFoundException])
|
||||
@{
|
||||
NS_VALUERETURN([self readDataFile: fallbackFilename]);
|
||||
return [self readDataFile: fallbackFilename];
|
||||
@}
|
||||
else if ([[localException name] isEqualToString: NSParseErrorException])
|
||||
@{
|
||||
NS_VALUERETURN([self readDataFileInOldFormat: filename]);
|
||||
return [self readDataFileInOldFormat: filename];
|
||||
@}
|
||||
else
|
||||
@{
|
||||
|
@ -113,13 +117,18 @@ occur, the code in the @code{NS_HANDLER} block is jumped to. Information on
|
|||
the error is passed to this code in the @code{localException} variable, which
|
||||
is an instance of @code{NSException}. The handler code examines the name of
|
||||
the exception to determine if it can implement a work-around. In the first
|
||||
two cases, an alternative approach is available, and so the
|
||||
@code{NS_VALUERETURN} macro is used to return an alternative value to the
|
||||
two cases, an alternative approach is available, and so an alternative value
|
||||
is returned.
|
||||
|
||||
If the file is found but the parse simply produces a nil parse tree, the
|
||||
@code{NS_VALUERETURN} macro is used to return nil to the
|
||||
@code{readDataFile:} caller. Note that it is @i{not} allowed to simply write
|
||||
``@code{return x;}'' inside an exception handler, owing to the nature of the
|
||||
``@code{return nil;}'' inside the NS_DURING block, owing to the nature of the
|
||||
behind-the-scenes C constructs implementing the mechanism (the @code{setjmp()}
|
||||
and @code{longjmp()} functions). If you are in a void function not returning
|
||||
a value, you may use simply ``@code{NS_VOIDRETURN}'' instead. Finally, notice
|
||||
a value, you may use simply ``@code{NS_VOIDRETURN}'' instead.
|
||||
|
||||
Finally, notice
|
||||
that in the third case above the handler does not recognize the exception
|
||||
type, so it passes it one level up to the caller by calling @code{-raise} on
|
||||
the exception object.
|
||||
|
|
Loading…
Reference in a new issue