mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 04:00:47 +00:00
Better support for setting errors inside -dataOfType:error: and -readFromData:ofType:error:.
Previously, under GNUstep, NSLocalizedFailureReasonKey was ignored when presented with +[NSAlert alertWithError]. Additionally, error set in -readFromData:ofType:error: was overwritten by two different methods in the file reading chain. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@38483 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
acf05990fa
commit
daa905a169
3 changed files with 24 additions and 4 deletions
|
@ -1789,10 +1789,17 @@ void NSBeginInformationalAlertSheet(NSString *title,
|
|||
{
|
||||
NSArray *options;
|
||||
NSUInteger count;
|
||||
NSString *errorText;
|
||||
|
||||
errorText = [error localizedFailureReason];
|
||||
if (errorText == nil)
|
||||
{
|
||||
errorText = [error localizedDescription];
|
||||
}
|
||||
|
||||
options = [error localizedRecoveryOptions];
|
||||
count = [options count];
|
||||
return [self alertWithMessageText: [error localizedDescription]
|
||||
return [self alertWithMessageText: errorText
|
||||
defaultButton: (count > 0) ? [options objectAtIndex: 0] : nil
|
||||
alternateButton: (count > 1) ? [options objectAtIndex: 1] : nil
|
||||
otherButton: (count > 2) ? [options objectAtIndex: 2] : nil
|
||||
|
|
|
@ -641,8 +641,9 @@ withContentsOfURL: (NSURL *)url
|
|||
|
||||
if (data == nil)
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
if (error && !(*error))
|
||||
*error = create_error(0, NSLocalizedString(@"Could not create data for type.",
|
||||
@"Error description"));
|
||||
return nil;
|
||||
}
|
||||
return AUTORELEASE([[NSFileWrapper alloc] initRegularFileWithContents: data]);
|
||||
|
@ -1022,7 +1023,7 @@ withContentsOfURL: (NSURL *)url
|
|||
error: error];
|
||||
if (wrapper == nil)
|
||||
{
|
||||
if (error)
|
||||
if (error && !(*error))
|
||||
{
|
||||
*error = create_error(0, NSLocalizedString(@"Could not write file wrapper.",
|
||||
@"Error description"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue