Author: ivucica
Date: Sun May 10 21:10:56 2015
New Revision: 38483
URL: http://svn.gna.org/viewcvs/gnustep?rev=38483&view=rev
Log:
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.
Modified:
libs/gui/trunk/ChangeLog
libs/gui/trunk/Source/NSAlert.m
libs/gui/trunk/Source/NSDocument.m
Modified: libs/gui/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/ChangeLog?rev=38483&r1=38482&r2=38483&view=diff
==============================================================================
--- libs/gui/trunk/ChangeLog (original)
+++ libs/gui/trunk/ChangeLog Sun May 10 21:10:56 2015
@@ -1,3 +1,15 @@
+2015-05-10 Ivan Vucica <[email protected]>
+
+ * Source/NSAlert.m (+alertWithError:): Support use of
+ NSLocalizedFailureReasonKey. Prefer it as the title of the error
+ alert's title in case it is present inside a NSError.
+ * Source/NSDocument.m (-fileWrapperOfType:error:): Prefer error
+ created by called -dataOfType:error: method; that is, do not overwrite
+ it.
+ * Source/NSDocument.m (-writeToURL:ofType:error:): Check that error is
+ non-nil, then apply the error message only if
+ -fileWrapperOfType:error: did not set its own error.
+
2015-04-03 Fred Kiefer <[email protected]>
* Headers/AppKit/NSColor.h,
Modified: libs/gui/trunk/Source/NSAlert.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSAlert.m?rev=38483&r1=38482&r2=38483&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSAlert.m (original)
+++ libs/gui/trunk/Source/NSAlert.m Sun May 10 21:10:56 2015
@@ -1789,10 +1789,17 @@
{
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
Modified: libs/gui/trunk/Source/NSDocument.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/trunk/Source/NSDocument.m?rev=38483&r1=38482&r2=38483&view=diff
==============================================================================
--- libs/gui/trunk/Source/NSDocument.m (original)
+++ libs/gui/trunk/Source/NSDocument.m Sun May 10 21:10:56 2015
@@ -641,8 +641,9 @@
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 @@
error: error];
if (wrapper == nil)
{
- if (error)
+ if (error && !(*error))
{
*error = create_error(0, NSLocalizedString(@"Could not write
file wrapper.",
@"Error
description"));
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs