]> err.no Git - sope/blob - sope-core/NGExtensions/FdExt.subproj/NSException+misc.m
do not escape URL safe chars (like @ or .)
[sope] / sope-core / NGExtensions / FdExt.subproj / NSException+misc.m
1 /*
2   Copyright (C) 2000-2004 SKYRIX Software AG
3
4   This file is part of OpenGroupware.org.
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #include "NSException+misc.h"
23 #include "common.h"
24
25 @implementation NSException(NGMiscellaneous)
26
27 - (id)initWithReason:(NSString *)_reason {
28   return [self initWithReason:_reason userInfo:nil];
29 }
30 - (id)initWithReason:(NSString *)_reason userInfo:(id)_userInfo {
31   return [self initWithName:NSStringFromClass([self class])
32                reason:_reason
33                userInfo:_userInfo];
34 }
35
36 - (id)initWithFormat:(NSString *)_format,... {
37   NSString *tmp = nil;
38   va_list  ap;
39   
40   if (_format == nil)
41     NSLog(@"ERROR(%s): missing format!", __PRETTY_FUNCTION__);
42   
43   va_start(ap, _format);
44   tmp = [[NSString allocWithZone:[self zone]]
45                    initWithFormat:_format ? _format : @"Exception"
46                    arguments:ap];
47   va_end(ap);
48
49   self = [self initWithReason:tmp userInfo:nil];
50   [tmp release]; tmp = nil;
51   return self;
52 }
53
54 /* NSCopying */
55
56 - (id)copyWithZone:(NSZone *)_zone {
57   // TODO: should make a real copy?
58   return [self retain];
59 }
60
61 @end /* NSException(NGMiscellaneous) */
62
63 #if COCOA_Foundation_LIBRARY || NeXT_Foundation_LIBRARY
64
65 @implementation NSException (NGLibFoundationCompatibility)
66 - (void)setReason:(NSString *)_reason {
67   [_reason retain];
68   [self->reason release];
69   self->reason = _reason;
70 }
71 @end
72
73 #elif GNUSTEP_BASE_LIBRARY
74
75 @implementation NSException (NGLibFoundationCompatibility)
76 - (void)setReason:(NSString *)_reason {
77   [_reason retain];
78   [self->_e_reason release];
79   self->_e_reason = _reason;
80 }
81 @end
82
83 #endif
84
85 void __link_NGExtensions_NSExceptionMisc() {
86   __link_NGExtensions_NSExceptionMisc();
87 }