mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
* Source/NSDocument.m: Add some NSError return values.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37619 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
26c365c9f0
commit
72f44c1ded
2 changed files with 41 additions and 10 deletions
|
@ -1,3 +1,7 @@
|
|||
2014-01-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSDocument.m: Add some NSError return values.
|
||||
|
||||
2014-01-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSTextAttachment.m: Add keyed coding.
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
*/
|
||||
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSFileManager.h>
|
||||
#import <Foundation/NSNotification.h>
|
||||
|
@ -48,6 +49,16 @@
|
|||
|
||||
#import "GSGuiPrivate.h"
|
||||
|
||||
static inline NSError*
|
||||
create_error(int code, NSString* desc)
|
||||
{
|
||||
return [NSError errorWithDomain: @"NSDocument"
|
||||
code: code
|
||||
userInfo: [NSDictionary
|
||||
dictionaryWithObjectsAndKeys: desc,
|
||||
NSLocalizedDescriptionKey, nil]];
|
||||
}
|
||||
|
||||
@implementation NSDocument
|
||||
|
||||
+ (NSArray *) readableTypes
|
||||
|
@ -629,8 +640,11 @@ withContentsOfURL: (NSURL *)url
|
|||
data = [self dataOfType: type error: error];
|
||||
|
||||
if (data == nil)
|
||||
return nil;
|
||||
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
return nil;
|
||||
}
|
||||
return AUTORELEASE([[NSFileWrapper alloc] initRegularFileWithContents: data]);
|
||||
}
|
||||
|
||||
|
@ -730,9 +744,11 @@ withContentsOfURL: (NSURL *)url
|
|||
error: error];
|
||||
}
|
||||
|
||||
// FIXME: Set error
|
||||
if (error)
|
||||
*error = nil;
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"File wrapper is no file.",
|
||||
@"Error description"));
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -894,6 +910,11 @@ withContentsOfURL: (NSURL *)url
|
|||
ofType: type
|
||||
saveOperation: op])
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not write backup file.",
|
||||
@"Error description"));
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -907,9 +928,11 @@ withContentsOfURL: (NSURL *)url
|
|||
|
||||
if (!isNativeType || (url == nil))
|
||||
{
|
||||
// FIXME: Set error
|
||||
if (error)
|
||||
*error = nil;
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Not a writable type or no URL given.",
|
||||
@"Error description"));
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
@ -927,9 +950,11 @@ withContentsOfURL: (NSURL *)url
|
|||
if (![self _writeBackupForFile: fileName
|
||||
toFile: backupFilename])
|
||||
{
|
||||
// FIXME: Set error.
|
||||
if (error)
|
||||
*error = nil;
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not write backup file.",
|
||||
@"Error description"));
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
@ -997,9 +1022,11 @@ withContentsOfURL: (NSURL *)url
|
|||
error: error];
|
||||
if (wrapper == nil)
|
||||
{
|
||||
// FIXME: Set error
|
||||
if (error)
|
||||
*error = nil;
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not write file wrapper.",
|
||||
@"Error description"));
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue