~ubuntu-branches/ubuntu/breezy/gnustep-base/breezy

« back to all changes in this revision

Viewing changes to Headers/Foundation/NSError.h

  • Committer: Bazaar Package Importer
  • Author(s): Eric Heintzmann
  • Date: 2005-04-17 00:14:38 UTC
  • mfrom: (1.2.1 upstream) (4 hoary)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20050417001438-enf0y07c9tku85z1
Tags: 1.10.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** Interface for NSError for GNUStep
 
2
   Copyright (C) 2004 Free Software Foundation, Inc.
 
3
 
 
4
   Written by:  Richard Frith-Macdonald <rfm@gnu.org>
 
5
   Date: May 2004
 
6
   
 
7
   This file is part of the GNUstep Base Library.
 
8
   
 
9
   This library is free software; you can redistribute it and/or
 
10
   modify it under the terms of the GNU Library General Public
 
11
   License as published by the Free Software Foundation; either
 
12
   version 2 of the License, or (at your option) any later version.
 
13
   
 
14
   This library is distributed in the hope that it will be useful,
 
15
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
   Library General Public License for more details.
 
18
   
 
19
   You should have received a copy of the GNU Library General Public
 
20
   License along with this library; if not, write to the Free
 
21
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
 
22
 
 
23
   AutogsdocSource: NSError.m
 
24
   */ 
 
25
 
 
26
#ifndef __NSError_h_GNUSTEP_BASE_INCLUDE
 
27
#define __NSError_h_GNUSTEP_BASE_INCLUDE
 
28
 
 
29
#ifndef STRICT_OPENSTEP
 
30
 
 
31
#include <Foundation/NSObject.h>
 
32
 
 
33
@class NSDictionary, NSString;
 
34
 
 
35
/**
 
36
 * Key for user info dictionary component which describes the error in
 
37
 * a human readable format.
 
38
 */
 
39
GS_EXPORT NSString* const NSLocalizedDescriptionKey;
 
40
 
 
41
/**
 
42
 * Where one error has caused another, the underlying error can be stored
 
43
 * in the user info dictionary uisng this key.
 
44
 */
 
45
GS_EXPORT NSString* const NSUnderlyingErrorKey;
 
46
 
 
47
/**
 
48
 * Domain for system errors (on MACH).
 
49
 */
 
50
GS_EXPORT NSString* const NSMACHErrorDomain;
 
51
/**
 
52
 * Domain for system errors.
 
53
 */
 
54
GS_EXPORT NSString* const NSOSStatusErrorDomain;
 
55
/**
 
56
 * Domain for system and system library errors.
 
57
 */
 
58
GS_EXPORT NSString* const NSPOSIXErrorDomain;
 
59
 
 
60
/**
 
61
 * Error information class.
 
62
 */
 
63
// TODO: document what this is for, especially since it's not in OS X
 
64
@interface NSError : NSObject <NSCopying, NSCoding>
 
65
{
 
66
@private
 
67
  int           _code;
 
68
  NSString      *_domain;
 
69
  NSDictionary  *_userInfo;
 
70
}
 
71
 
 
72
/**
 
73
 * Creates and returns an autoreleased NSError instance by calling
 
74
 * -initWithDomain:code:userInfo:
 
75
 */
 
76
+ (id) errorWithDomain: (NSString*)aDomain
 
77
                  code: (int)aCode
 
78
              userInfo: (NSDictionary*)aDictionary;
 
79
 
 
80
/**
 
81
 * Return the error code ... which is not globally unique, just unique for
 
82
 * a particular domain.
 
83
 */
 
84
- (int) code;
 
85
 
 
86
/**
 
87
 * Return the domain for this instance.
 
88
 */
 
89
- (NSString*) domain;
 
90
 
 
91
/** <init />
 
92
 * Initialises the receiver using the supplied domain, code, and info.<br />
 
93
 * The domain must be non-nil.
 
94
 */
 
95
- (id) initWithDomain: (NSString*)aDomain
 
96
                 code: (int)aCode
 
97
             userInfo: (NSDictionary*)aDictionary;
 
98
 
 
99
/** <override-subclass />
 
100
 * Return a human readable description for the error.<br />
 
101
 * The default implementation uses the value from the user info dictionary
 
102
 * if it is available, otherwise it generates a generic one from domain
 
103
 * and code.
 
104
 */
 
105
- (NSString *)localizedDescription;
 
106
 
 
107
/**
 
108
 * Return the user info for this instance (or nil if none is set)<br />
 
109
 * The <code>NSLocalizedDescriptionKey</code> should locate a human readable
 
110
 * description in the dictionary.<br /> 
 
111
 * The <code>NSUnderlyingErrorKey</code> key should locate an
 
112
 * <code>NSError</code> instance if an error is available describing any
 
113
 * underlying problem.<br />
 
114
 */
 
115
- (NSDictionary*) userInfo;
 
116
@end
 
117
 
 
118
#endif  /* STRICT_OPENSTEP */
 
119
#endif  /* __NSError_h_GNUSTEP_BASE_INCLUDE*/