2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
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
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.
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
23 #include "XmlRpcMethodResponse.h"
25 #include "XmlRpcCoder.h"
27 @implementation NSException(XmlRpcCoding)
29 - (NSString *)xmlRpcType {
33 - (NSNumber *)xmlRpcFaultCode {
39 if ((code = [ui objectForKey:@"XmlRpcFaultCode"]))
41 else if ((code = [ui objectForKey:@"faultCode"]))
46 return [NSNumber numberWithInt:[code intValue]];
49 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
51 NSString *str, *n, *r;
54 code = [[self xmlRpcFaultCode] intValue];
61 else if ([r length] == 0)
64 str = [NSString stringWithFormat:@"%@: %@", n, r];
66 if ((ui = [self userInfo]))
67 str = [NSString stringWithFormat:@"%@ %@", str, ui];
69 [_coder encodeInt:code forKey:@"faultCode"];
70 [_coder encodeString:str forKey:@"faultString"];
73 + (NSString *)exceptionNameForXmlRpcFaultCode:(int)_code {
74 return [NSString stringWithFormat:@"XmlRpcFault<%i>", _code];
76 - (NSString *)exceptionNameForXmlRpcFaultCode:(int)_code {
77 return [[self class] exceptionNameForXmlRpcFaultCode:_code];
80 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
85 code = [_coder decodeIntForKey:@"faultCode"];
86 r = [_coder decodeStringForKey:@"faultString"];
87 ui = [NSDictionary dictionaryWithObjectsAndKeys:
88 [NSNumber numberWithInt:code], @"faultCode",
92 return [self exceptionWithName:
93 [self exceptionNameForXmlRpcFaultCode:code]
98 @end /* NSException(XmlRpcCoding) */