forked from EFEducationFirstMobile/librabbitmq-objc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAMQPError.m
More file actions
42 lines (34 loc) · 1.13 KB
/
AMQPError.m
File metadata and controls
42 lines (34 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//
// AMQPError.m
// AMQPKit
//
// Created by Andrew Mackenzie-Ross on 23/02/2015.
// Copyright (c) 2015 librabbitmq. All rights reserved.
//
#import "AMQPError.h"
#import "AMQPErrorDecoder.h"
@implementation AMQPError
+ (NSString *)domain
{
return @"com.amqpkit.error";
}
+ (instancetype)errorWithCode:(AMQPErrorCode)code userInfo:(NSDictionary *)userInfo
{
return [self errorWithDomain:[self domain] code:code userInfo:userInfo];
}
+ (instancetype)errorWithCode:(AMQPErrorCode)code reply_t:(amqp_rpc_reply_t)reply
{
NSString *errorDescription = [AMQPErrorDecoder errorDescriptionForReply:reply];
NSDictionary *userInfo = (errorDescription ? @{ NSLocalizedDescriptionKey: errorDescription } : nil);
return [self errorWithCode:code userInfo:userInfo];
}
+ (instancetype)errorWithCode:(AMQPErrorCode)code format:(NSString *)format, ...
{
va_list va;
va_start(va, format);
NSString *string = [[NSString alloc] initWithFormat:format arguments:va];
va_end(va);
NSDictionary *userInfo = (string ? @{ NSLocalizedDescriptionKey: string } : nil);
return [self errorWithCode:code userInfo:userInfo];
}
@end