mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:10:48 +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
f336c2b81f
commit
e7fc793f00
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>
|
2014-01-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSTextAttachment.m: Add keyed coding.
|
* Source/NSTextAttachment.m: Add keyed coding.
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import <Foundation/NSData.h>
|
#import <Foundation/NSData.h>
|
||||||
|
#import <Foundation/NSError.h>
|
||||||
#import <Foundation/NSException.h>
|
#import <Foundation/NSException.h>
|
||||||
#import <Foundation/NSFileManager.h>
|
#import <Foundation/NSFileManager.h>
|
||||||
#import <Foundation/NSNotification.h>
|
#import <Foundation/NSNotification.h>
|
||||||
|
@ -48,6 +49,16 @@
|
||||||
|
|
||||||
#import "GSGuiPrivate.h"
|
#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
|
@implementation NSDocument
|
||||||
|
|
||||||
+ (NSArray *) readableTypes
|
+ (NSArray *) readableTypes
|
||||||
|
@ -629,8 +640,11 @@ withContentsOfURL: (NSURL *)url
|
||||||
data = [self dataOfType: type error: error];
|
data = [self dataOfType: type error: error];
|
||||||
|
|
||||||
if (data == nil)
|
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]);
|
return AUTORELEASE([[NSFileWrapper alloc] initRegularFileWithContents: data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -730,9 +744,11 @@ withContentsOfURL: (NSURL *)url
|
||||||
error: error];
|
error: error];
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Set error
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = nil;
|
{
|
||||||
|
*error = create_error(0, NSLocalizedString(@"File wrapper is no file.",
|
||||||
|
@"Error description"));
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,6 +910,11 @@ withContentsOfURL: (NSURL *)url
|
||||||
ofType: type
|
ofType: type
|
||||||
saveOperation: op])
|
saveOperation: op])
|
||||||
{
|
{
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
*error = create_error(0, NSLocalizedString(@"Could not write backup file.",
|
||||||
|
@"Error description"));
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,9 +928,11 @@ withContentsOfURL: (NSURL *)url
|
||||||
|
|
||||||
if (!isNativeType || (url == nil))
|
if (!isNativeType || (url == nil))
|
||||||
{
|
{
|
||||||
// FIXME: Set error
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = nil;
|
{
|
||||||
|
*error = create_error(0, NSLocalizedString(@"Not a writable type or no URL given.",
|
||||||
|
@"Error description"));
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -927,9 +950,11 @@ withContentsOfURL: (NSURL *)url
|
||||||
if (![self _writeBackupForFile: fileName
|
if (![self _writeBackupForFile: fileName
|
||||||
toFile: backupFilename])
|
toFile: backupFilename])
|
||||||
{
|
{
|
||||||
// FIXME: Set error.
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = nil;
|
{
|
||||||
|
*error = create_error(0, NSLocalizedString(@"Could not write backup file.",
|
||||||
|
@"Error description"));
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -997,9 +1022,11 @@ withContentsOfURL: (NSURL *)url
|
||||||
error: error];
|
error: error];
|
||||||
if (wrapper == nil)
|
if (wrapper == nil)
|
||||||
{
|
{
|
||||||
// FIXME: Set error
|
|
||||||
if (error)
|
if (error)
|
||||||
*error = nil;
|
{
|
||||||
|
*error = create_error(0, NSLocalizedString(@"Could not write file wrapper.",
|
||||||
|
@"Error description"));
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue