Exception: MonkeyWrench::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/monkey_wrench/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code, extra_fields = {}) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
# File 'lib/monkey_wrench/error.rb', line 5

def initialize(message, code, extra_fields = {}) 
  super(message)
  @code = code
  @extra_fields = extra_fields
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(sym, *args, &block) ⇒ Object



15
16
17
# File 'lib/monkey_wrench/error.rb', line 15

def method_missing(sym, *args, &block)
  return @extra_fields[sym.to_s] if @extra_fields.has_key?(sym.to_s)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



3
4
5
# File 'lib/monkey_wrench/error.rb', line 3

def code
  @code
end

Instance Method Details

#typeObject



11
12
13
# File 'lib/monkey_wrench/error.rb', line 11

def type
  types[@code]
end

#typesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/monkey_wrench/error.rb', line 19

def types
  {
    -32601 => 'ServerError_MethodUnknown',
    -32602 => 'ServerError_InvalidParameters',
    -99 => 'Unknown_Exception',
    -98 => 'Request_TimedOut',
    -92 => 'Zend_Uri_Exception',
    -91 => 'PDOException',
    -91 => 'Avesta_Db_Exception',
    -90 => 'XML_RPC2_Exception',
    -90 => 'XML_RPC2_FaultException',
    -50 => 'Too_Many_Connections',
    0 => 'Parse_Exception',
    100 => 'User_Unknown',
    101 => 'User_Disabled',
    102 => 'User_DoesNotExist',
    103 => 'User_NotApproved',
    104 => 'Invalid_ApiKey',
    105 => 'User_UnderMaintenance',
    120 => 'User_InvalidAction',
    121 => 'User_MissingEmail',
    122 => 'User_CannotSendCampaign',
    123 => 'User_MissingModuleOutbox',
    124 => 'User_ModuleAlreadyPurchased',
    125 => 'User_ModuleNotPurchased',
    126 => 'User_NotEnoughCredit',
    127 => 'MC_InvalidPayment',
    200 => 'List_DoesNotExist',
    210 => 'List_InvalidInterestFieldType',
    211 => 'List_InvalidOption',
    212 => 'List_InvalidUnsubMember',
    213 => 'List_InvalidBounceMember',
    214 => 'List_AlreadySubscribed',
    215 => 'List_NotSubscribed',
    220 => 'List_InvalidImport',
    221 => 'MC_PastedList_Duplicate',
    222 => 'MC_PastedList_InvalidImport',
    230 => 'Email_AlreadySubscribed',
    231 => 'Email_AlreadyUnsubscribed',
    232 => 'Email_NotExists',
    233 => 'Email_NotSubscribed',
    250 => 'List_MergeFieldRequired',
    251 => 'List_CannotRemoveEmailMerge',
    252 => 'List_Merge_InvalidMergeID',
    253 => 'List_TooManyMergeFields',
    254 => 'List_InvalidMergeField',
    270 => 'List_InvalidInterestGroup',
    271 => 'List_TooManyInterestGroups',
    300 => 'Campaign_DoesNotExist',
    301 => 'Campaign_StatsNotAvailable',
    310 => 'Campaign_InvalidAbsplit',
    311 => 'Campaign_InvalidContent',
    312 => 'Campaign_InvalidOption',
    313 => 'Campaign_InvalidStatus',
    314 => 'Campaign_NotSaved',
    315 => 'Campaign_InvalidSegment',
    316 => 'Campaign_InvalidRss',
    317 => 'Campaign_InvalidAuto',
    318 => 'MC_ContentImport_InvalidArchive',
    330 => 'Invalid_EcommOrder',
    350 => 'Absplit_UnknownError',
    351 => 'Absplit_UnknownSplitTest',
    352 => 'Absplit_UnknownTestType',
    353 => 'Absplit_UnknownWaitUnit',
    354 => 'Absplit_UnknownWinnerType',
    355 => 'Absplit_WinnerNotSelected',
    500 => 'Invalid_Analytics',
    501 => 'Invalid_DateTime',
    502 => 'Invalid_Email',
    503 => 'Invalid_SendType',
    504 => 'Invalid_Template',
    505 => 'Invalid_TrackingOptions',
    506 => 'Invalid_Options',
    507 => 'Invalid_Folder',
    508 => 'Invalid_URL',
    550 => 'Module_Unknown',
    551 => 'MonthlyPlan_Unknown',
    552 => 'Order_TypeUnknown',
    553 => 'Invalid_PagingLimit',
    554 => 'Invalid_PagingStart'
  }
end