2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "XmlRpcMethodResponse.h"
24 #include "XmlRpcCoder.h"
26 @implementation NSException(XmlRpcCoding)
28 - (NSString *)xmlRpcType {
32 - (NSNumber *)xmlRpcFaultCode {
38 if ((code = [ui objectForKey:@"XmlRpcFaultCode"]))
40 else if ((code = [ui objectForKey:@"faultCode"]))
45 return [NSNumber numberWithInt:[code intValue]];
48 - (void)encodeWithXmlRpcCoder:(XmlRpcEncoder *)_coder {
50 NSString *str, *n, *r;
53 code = [[self xmlRpcFaultCode] intValue];
60 else if ([r length] == 0)
63 str = [NSString stringWithFormat:@"%@: %@", n, r];
65 if ((ui = [self userInfo]))
66 str = [NSString stringWithFormat:@"%@ %@", str, ui];
68 [_coder encodeInt:code forKey:@"faultCode"];
69 [_coder encodeString:str forKey:@"faultString"];
72 + (NSString *)exceptionNameForXmlRpcFaultCode:(int)_code {
73 return [NSString stringWithFormat:@"XmlRpcFault<%i>", _code];
75 - (NSString *)exceptionNameForXmlRpcFaultCode:(int)_code {
76 return [[self class] exceptionNameForXmlRpcFaultCode:_code];
79 + (id)decodeObjectWithXmlRpcCoder:(XmlRpcDecoder *)_coder {
84 code = [_coder decodeIntForKey:@"faultCode"];
85 r = [_coder decodeStringForKey:@"faultString"];
86 ui = [NSDictionary dictionaryWithObjectsAndKeys:
87 [NSNumber numberWithInt:code], @"faultCode",
91 return [self exceptionWithName:
92 [self exceptionNameForXmlRpcFaultCode:code]
97 @end /* NSException(XmlRpcCoding) */