servus 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -0
  3. data/CHANGELOG.md +8 -1
  4. data/IDEAS.md +5 -0
  5. data/READme.md +147 -42
  6. data/Rakefile +33 -0
  7. data/builds/servus-0.1.2.gem +0 -0
  8. data/builds/servus-0.1.3.gem +0 -0
  9. data/builds/servus-0.1.4.gem +0 -0
  10. data/docs/core/1_overview.md +77 -0
  11. data/docs/core/2_architecture.md +92 -0
  12. data/docs/core/3_service_objects.md +121 -0
  13. data/docs/features/1_schema_validation.md +119 -0
  14. data/docs/features/2_error_handling.md +121 -0
  15. data/docs/features/3_async_execution.md +81 -0
  16. data/docs/features/4_logging.md +64 -0
  17. data/docs/guides/1_common_patterns.md +90 -0
  18. data/docs/guides/2_migration_guide.md +175 -0
  19. data/docs/integration/1_configuration.md +51 -0
  20. data/docs/integration/2_testing.md +164 -0
  21. data/docs/integration/3_rails_integration.md +99 -0
  22. data/docs/yard/Servus/Base.html +1645 -0
  23. data/docs/yard/Servus/Config.html +582 -0
  24. data/docs/yard/Servus/Extensions/Async/Call.html +400 -0
  25. data/docs/yard/Servus/Extensions/Async/Errors/AsyncError.html +140 -0
  26. data/docs/yard/Servus/Extensions/Async/Errors/JobEnqueueError.html +154 -0
  27. data/docs/yard/Servus/Extensions/Async/Errors/ServiceNotFoundError.html +154 -0
  28. data/docs/yard/Servus/Extensions/Async/Errors.html +128 -0
  29. data/docs/yard/Servus/Extensions/Async/Ext.html +119 -0
  30. data/docs/yard/Servus/Extensions/Async/Job.html +310 -0
  31. data/docs/yard/Servus/Extensions/Async.html +141 -0
  32. data/docs/yard/Servus/Extensions.html +117 -0
  33. data/docs/yard/Servus/Generators/ServiceGenerator.html +261 -0
  34. data/docs/yard/Servus/Generators.html +115 -0
  35. data/docs/yard/Servus/Helpers/ControllerHelpers.html +457 -0
  36. data/docs/yard/Servus/Helpers.html +115 -0
  37. data/docs/yard/Servus/Railtie.html +134 -0
  38. data/docs/yard/Servus/Support/Errors/AuthenticationError.html +287 -0
  39. data/docs/yard/Servus/Support/Errors/BadRequestError.html +283 -0
  40. data/docs/yard/Servus/Support/Errors/ForbiddenError.html +284 -0
  41. data/docs/yard/Servus/Support/Errors/InternalServerError.html +283 -0
  42. data/docs/yard/Servus/Support/Errors/NotFoundError.html +284 -0
  43. data/docs/yard/Servus/Support/Errors/ServiceError.html +489 -0
  44. data/docs/yard/Servus/Support/Errors/ServiceUnavailableError.html +290 -0
  45. data/docs/yard/Servus/Support/Errors/UnauthorizedError.html +200 -0
  46. data/docs/yard/Servus/Support/Errors/UnprocessableEntityError.html +288 -0
  47. data/docs/yard/Servus/Support/Errors/ValidationError.html +200 -0
  48. data/docs/yard/Servus/Support/Errors.html +140 -0
  49. data/docs/yard/Servus/Support/Logger.html +856 -0
  50. data/docs/yard/Servus/Support/Rescuer/BlockContext.html +585 -0
  51. data/docs/yard/Servus/Support/Rescuer/CallOverride.html +257 -0
  52. data/docs/yard/Servus/Support/Rescuer/ClassMethods.html +343 -0
  53. data/docs/yard/Servus/Support/Rescuer.html +267 -0
  54. data/docs/yard/Servus/Support/Response.html +574 -0
  55. data/docs/yard/Servus/Support/Validator.html +1150 -0
  56. data/docs/yard/Servus/Support.html +119 -0
  57. data/docs/yard/Servus/Testing/ExampleBuilders.html +523 -0
  58. data/docs/yard/Servus/Testing/ExampleExtractor.html +578 -0
  59. data/docs/yard/Servus/Testing.html +142 -0
  60. data/docs/yard/Servus.html +343 -0
  61. data/docs/yard/_index.html +535 -0
  62. data/docs/yard/class_list.html +54 -0
  63. data/docs/yard/css/common.css +1 -0
  64. data/docs/yard/css/full_list.css +58 -0
  65. data/docs/yard/css/style.css +503 -0
  66. data/docs/yard/file.1_common_patterns.html +154 -0
  67. data/docs/yard/file.1_configuration.html +115 -0
  68. data/docs/yard/file.1_overview.html +142 -0
  69. data/docs/yard/file.1_schema_validation.html +188 -0
  70. data/docs/yard/file.2_architecture.html +157 -0
  71. data/docs/yard/file.2_error_handling.html +190 -0
  72. data/docs/yard/file.2_migration_guide.html +242 -0
  73. data/docs/yard/file.2_testing.html +227 -0
  74. data/docs/yard/file.3_async_execution.html +145 -0
  75. data/docs/yard/file.3_rails_integration.html +160 -0
  76. data/docs/yard/file.3_service_objects.html +191 -0
  77. data/docs/yard/file.4_logging.html +135 -0
  78. data/docs/yard/file.ErrorHandling.html +190 -0
  79. data/docs/yard/file.READme.html +674 -0
  80. data/docs/yard/file.architecture.html +157 -0
  81. data/docs/yard/file.async_execution.html +145 -0
  82. data/docs/yard/file.common_patterns.html +154 -0
  83. data/docs/yard/file.configuration.html +115 -0
  84. data/docs/yard/file.error_handling.html +190 -0
  85. data/docs/yard/file.logging.html +135 -0
  86. data/docs/yard/file.migration_guide.html +242 -0
  87. data/docs/yard/file.overview.html +142 -0
  88. data/docs/yard/file.rails_integration.html +160 -0
  89. data/docs/yard/file.schema_validation.html +188 -0
  90. data/docs/yard/file.service_objects.html +191 -0
  91. data/docs/yard/file.testing.html +227 -0
  92. data/docs/yard/file_list.html +119 -0
  93. data/docs/yard/frames.html +22 -0
  94. data/docs/yard/index.html +674 -0
  95. data/docs/yard/js/app.js +344 -0
  96. data/docs/yard/js/full_list.js +242 -0
  97. data/docs/yard/js/jquery.js +4 -0
  98. data/docs/yard/method_list.html +542 -0
  99. data/docs/yard/top-level-namespace.html +110 -0
  100. data/lib/generators/servus/service/service_generator.rb +64 -1
  101. data/lib/generators/servus/service/templates/service.rb.erb +1 -1
  102. data/lib/servus/base.rb +258 -57
  103. data/lib/servus/config.rb +58 -12
  104. data/lib/servus/extensions/async/call.rb +50 -18
  105. data/lib/servus/extensions/async/errors.rb +23 -3
  106. data/lib/servus/extensions/async/ext.rb +10 -2
  107. data/lib/servus/extensions/async/job.rb +32 -11
  108. data/lib/servus/helpers/controller_helpers.rb +73 -37
  109. data/lib/servus/support/errors.rb +135 -45
  110. data/lib/servus/support/rescuer.rb +189 -36
  111. data/lib/servus/support/response.rb +49 -7
  112. data/lib/servus/support/validator.rb +120 -19
  113. data/lib/servus/testing/example_builders.rb +133 -0
  114. data/lib/servus/testing/example_extractor.rb +309 -0
  115. data/lib/servus/testing.rb +17 -0
  116. data/lib/servus/version.rb +1 -1
  117. metadata +118 -19
@@ -0,0 +1,257 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: Servus::Support::Rescuer::CallOverride
8
+
9
+ &mdash; Servus | Service Object Framework
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Servus::Support::Rescuer::CallOverride";
19
+ relpath = '../../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../Servus.html" title="Servus (module)">Servus</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Support.html" title="Servus::Support (module)">Support</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Rescuer.html" title="Servus::Support::Rescuer (module)">Rescuer</a></span></span>
41
+ &raquo;
42
+ <span class="title">CallOverride</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: Servus::Support::Rescuer::CallOverride
63
+
64
+
65
+ <span class="private note title">Private</span>
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/servus/support/rescuer.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+ <p class="note private">
89
+ <strong>This module is part of a private API.</strong>
90
+ You should avoid using this module if possible, as it may be removed or be changed in the future.
91
+ </p>
92
+ <p>Wraps the service&#39;s .call method with error handling logic.</p>
93
+
94
+ <p>This module is prepended to the service&#39;s singleton class, allowing it to
95
+ intercept calls and add rescue behavior before delegating to the original implementation.</p>
96
+
97
+
98
+ </div>
99
+ </div>
100
+ <div class="tags">
101
+
102
+
103
+ </div>
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <h2>
112
+ Instance Method Summary
113
+ <small><a href="#" class="summary_toggle">collapse</a></small>
114
+ </h2>
115
+
116
+ <ul class="summary">
117
+
118
+ <li class="public ">
119
+ <span class="summary_signature">
120
+
121
+ <a href="#call-instance_method" title="#call (instance method)">#<strong>call</strong>(**args) &#x21d2; Servus::Support::Response </a>
122
+
123
+
124
+
125
+ </span>
126
+
127
+
128
+
129
+
130
+
131
+
132
+ <span class="private note title">private</span>
133
+
134
+
135
+ <span class="summary_desc"><div class='inline'><p>Wraps the service call with automatic error rescue.</p>
136
+ </div></span>
137
+
138
+ </li>
139
+
140
+
141
+ </ul>
142
+
143
+
144
+
145
+
146
+ <div id="instance_method_details" class="method_details_list">
147
+ <h2>Instance Method Details</h2>
148
+
149
+
150
+ <div class="method_details first">
151
+ <h3 class="signature first" id="call-instance_method">
152
+
153
+ #<strong>call</strong>(**args) &#x21d2; <tt><span class='object_link'><a href="../Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>
154
+
155
+
156
+
157
+
158
+
159
+ </h3><div class="docstring">
160
+ <div class="discussion">
161
+ <p class="note private">
162
+ <strong>This method is part of a private API.</strong>
163
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
164
+ </p>
165
+ <p>Wraps the service call with automatic error rescue.</p>
166
+
167
+ <p>If rescuable_errors are configured, wraps the call in a rescue block.
168
+ Caught exceptions are converted to failure responses using <span class='object_link'>#handle_failure</span>.</p>
169
+
170
+
171
+ </div>
172
+ </div>
173
+ <div class="tags">
174
+ <p class="tag_title">Parameters:</p>
175
+ <ul class="param">
176
+
177
+ <li>
178
+
179
+ <span class='name'>args</span>
180
+
181
+
182
+ <span class='type'>(<tt>Hash</tt>)</span>
183
+
184
+
185
+
186
+ &mdash;
187
+ <div class='inline'><p>keyword arguments passed to the service</p>
188
+ </div>
189
+
190
+ </li>
191
+
192
+ </ul>
193
+
194
+ <p class="tag_title">Returns:</p>
195
+ <ul class="return">
196
+
197
+ <li>
198
+
199
+
200
+ <span class='type'>(<tt><span class='object_link'><a href="../Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
201
+
202
+
203
+
204
+ &mdash;
205
+ <div class='inline'><p>the service result or failure response</p>
206
+ </div>
207
+
208
+ </li>
209
+
210
+ </ul>
211
+
212
+ </div><table class="source_code">
213
+ <tr>
214
+ <td>
215
+ <pre class="lines">
216
+
217
+
218
+ 153
219
+ 154
220
+ 155
221
+ 156
222
+ 157
223
+ 158
224
+ 159
225
+ 160
226
+ 161</pre>
227
+ </td>
228
+ <td>
229
+ <pre class="code"><span class="info file"># File 'lib/servus/support/rescuer.rb', line 153</span>
230
+
231
+ <span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='op'>**</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
232
+ <span class='kw'>return</span> <span class='kw'>super</span> <span class='kw'>if</span> <span class='id identifier rubyid_rescuable_configs'>rescuable_configs</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
233
+
234
+ <span class='kw'>begin</span>
235
+ <span class='kw'>super</span>
236
+ <span class='kw'>rescue</span> <span class='const'>StandardError</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
237
+ <span class='id identifier rubyid_handle_rescued_error'>handle_rescued_error</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_raise'>raise</span>
238
+ <span class='kw'>end</span>
239
+ <span class='kw'>end</span></pre>
240
+ </td>
241
+ </tr>
242
+ </table>
243
+ </div>
244
+
245
+ </div>
246
+
247
+ </div>
248
+
249
+ <div id="footer">
250
+ Generated on Fri Nov 21 00:33:23 2025 by
251
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
252
+ 0.9.37 (ruby-3.4.4).
253
+ </div>
254
+
255
+ </div>
256
+ </body>
257
+ </html>
@@ -0,0 +1,343 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: Servus::Support::Rescuer::ClassMethods
8
+
9
+ &mdash; Servus | Service Object Framework
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../../../css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="../../../css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "Servus::Support::Rescuer::ClassMethods";
19
+ relpath = '../../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../../_index.html">Index (C)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../../Servus.html" title="Servus (module)">Servus</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Support.html" title="Servus::Support (module)">Support</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Rescuer.html" title="Servus::Support::Rescuer (module)">Rescuer</a></span></span>
41
+ &raquo;
42
+ <span class="title">ClassMethods</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../../../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: Servus::Support::Rescuer::ClassMethods
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/servus/support/rescuer.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+ <p>Class methods for rescue_from</p>
89
+
90
+
91
+ </div>
92
+ </div>
93
+ <div class="tags">
94
+
95
+
96
+ </div>
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ <h2>
105
+ Instance Method Summary
106
+ <small><a href="#" class="summary_toggle">collapse</a></small>
107
+ </h2>
108
+
109
+ <ul class="summary">
110
+
111
+ <li class="public ">
112
+ <span class="summary_signature">
113
+
114
+ <a href="#rescue_from-instance_method" title="#rescue_from (instance method)">#<strong>rescue_from</strong>(*errors, use: Servus::Support::Errors::ServiceError) {|exception| ... } &#x21d2; Object </a>
115
+
116
+
117
+
118
+ </span>
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+ <span class="summary_desc"><div class='inline'><p>Configures automatic error handling for the service.</p>
129
+ </div></span>
130
+
131
+ </li>
132
+
133
+
134
+ </ul>
135
+
136
+
137
+
138
+
139
+ <div id="instance_method_details" class="method_details_list">
140
+ <h2>Instance Method Details</h2>
141
+
142
+
143
+ <div class="method_details first">
144
+ <h3 class="signature first" id="rescue_from-instance_method">
145
+
146
+ #<strong>rescue_from</strong>(*errors, use: Servus::Support::Errors::ServiceError) {|exception| ... } &#x21d2; <tt>Object</tt>
147
+
148
+
149
+
150
+
151
+
152
+ </h3><div class="docstring">
153
+ <div class="discussion">
154
+ <p>Configures automatic error handling for the service.</p>
155
+
156
+ <p>Declares which exception classes should be automatically rescued and converted
157
+ to failure responses. Without a block, exceptions are wrapped in the specified
158
+ ServiceError type with a formatted message including the original exception details.</p>
159
+
160
+ <p>When a block is provided, it receives the exception and must return either
161
+ <code>success(data)</code> or <code>failure(message, type:)</code> to create the response.</p>
162
+
163
+
164
+ </div>
165
+ </div>
166
+ <div class="tags">
167
+
168
+ <div class="examples">
169
+ <h4 class="tag_title">Examples:</h4>
170
+
171
+
172
+ <h5 class="example_title"><div class='inline'><p>Basic usage with default error type:</p>
173
+ </div></h5>
174
+
175
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>TestService</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Base.html" title="Servus::Base (class)">Base</a></span></span>
176
+ <span class='id identifier rubyid_rescue_from'>rescue_from</span> <span class='const'>Net</span><span class='op'>::</span><span class='const'>HTTPError</span><span class='comma'>,</span> <span class='const'>Timeout</span><span class='op'>::</span><span class='const'>Error</span><span class='comma'>,</span> <span class='label'>use:</span> <span class='const'>ServiceUnavailableError</span>
177
+ <span class='kw'>end</span></code></pre>
178
+
179
+
180
+ <h5 class="example_title"><div class='inline'><p>Custom error handling with block:</p>
181
+ </div></h5>
182
+
183
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>TestService</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Base.html" title="Servus::Base (class)">Base</a></span></span>
184
+ <span class='id identifier rubyid_rescue_from'>rescue_from</span> <span class='const'>ActiveRecord</span><span class='op'>::</span><span class='const'>RecordInvalid</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_exception'>exception</span><span class='op'>|</span>
185
+ <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Validation failed: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_exception'>exception</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>ValidationError</span><span class='rparen'>)</span>
186
+ <span class='kw'>end</span>
187
+ <span class='kw'>end</span></code></pre>
188
+
189
+
190
+ <h5 class="example_title"><div class='inline'><p>Recovering from errors with success:</p>
191
+ </div></h5>
192
+
193
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>TestService</span> <span class='op'>&lt;</span> <span class='const'><span class='object_link'><a href="../../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Base.html" title="Servus::Base (class)">Base</a></span></span>
194
+ <span class='id identifier rubyid_rescue_from'>rescue_from</span> <span class='const'>Stripe</span><span class='op'>::</span><span class='const'>CardError</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_exception'>exception</span><span class='op'>|</span>
195
+ <span class='kw'>if</span> <span class='id identifier rubyid_exception'>exception</span><span class='period'>.</span><span class='id identifier rubyid_code'>code</span> <span class='op'>==</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>card_declined</span><span class='tstring_end'>&#39;</span></span>
196
+ <span class='id identifier rubyid_failure'>failure</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Card declined</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='label'>type:</span> <span class='const'>BadRequestError</span><span class='rparen'>)</span>
197
+ <span class='kw'>else</span>
198
+ <span class='id identifier rubyid_success'>success</span><span class='lparen'>(</span><span class='label'>recovered:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>fallback_used:</span> <span class='kw'>true</span><span class='rparen'>)</span>
199
+ <span class='kw'>end</span>
200
+ <span class='kw'>end</span>
201
+ <span class='kw'>end</span></code></pre>
202
+
203
+ </div>
204
+ <p class="tag_title">Parameters:</p>
205
+ <ul class="param">
206
+
207
+ <li>
208
+
209
+ <span class='name'>errors</span>
210
+
211
+
212
+ <span class='type'>(<tt>Class&lt;StandardError&gt;</tt>)</span>
213
+
214
+
215
+
216
+ &mdash;
217
+ <div class='inline'><p>One or more exception classes to rescue from</p>
218
+ </div>
219
+
220
+ </li>
221
+
222
+ <li>
223
+
224
+ <span class='name'>use</span>
225
+
226
+
227
+ <span class='type'>(<tt>Class&lt;<span class='object_link'><a href="../Errors/ServiceError.html" title="Servus::Support::Errors::ServiceError (class)">Servus::Support::Errors::ServiceError</a></span>&gt;</tt>)</span>
228
+
229
+
230
+ <em class="default">(defaults to: <tt>Servus::Support::Errors::ServiceError</tt>)</em>
231
+
232
+
233
+ &mdash;
234
+ <div class='inline'><p>Error class to use when wrapping exceptions
235
+ (only used without block)</p>
236
+ </div>
237
+
238
+ </li>
239
+
240
+ </ul>
241
+
242
+ <p class="tag_title">Yields:</p>
243
+ <ul class="yield">
244
+
245
+ <li>
246
+
247
+
248
+ <span class='type'>(<tt>exception</tt>)</span>
249
+
250
+
251
+
252
+ &mdash;
253
+ <div class='inline'><p>Optional block for custom error handling</p>
254
+ </div>
255
+
256
+ </li>
257
+
258
+ </ul>
259
+ <p class="tag_title">Yield Parameters:</p>
260
+ <ul class="yieldparam">
261
+
262
+ <li>
263
+
264
+ <span class='name'>exception</span>
265
+
266
+
267
+ <span class='type'>(<tt>StandardError</tt>)</span>
268
+
269
+
270
+
271
+ &mdash;
272
+ <div class='inline'><p>The caught exception</p>
273
+ </div>
274
+
275
+ </li>
276
+
277
+ </ul>
278
+ <p class="tag_title">Yield Returns:</p>
279
+ <ul class="yieldreturn">
280
+
281
+ <li>
282
+
283
+
284
+ <span class='type'>(<tt><span class='object_link'><a href="../Response.html" title="Servus::Support::Response (class)">Servus::Support::Response</a></span></tt>)</span>
285
+
286
+
287
+
288
+ &mdash;
289
+ <div class='inline'><p>Must return success() or failure() response</p>
290
+ </div>
291
+
292
+ </li>
293
+
294
+ </ul>
295
+
296
+ </div><table class="source_code">
297
+ <tr>
298
+ <td>
299
+ <pre class="lines">
300
+
301
+
302
+ 125
303
+ 126
304
+ 127
305
+ 128
306
+ 129
307
+ 130
308
+ 131
309
+ 132
310
+ 133
311
+ 134</pre>
312
+ </td>
313
+ <td>
314
+ <pre class="code"><span class="info file"># File 'lib/servus/support/rescuer.rb', line 125</span>
315
+
316
+ <span class='kw'>def</span> <span class='id identifier rubyid_rescue_from'>rescue_from</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_errors'>errors</span><span class='comma'>,</span> <span class='label'>use:</span> <span class='const'><span class='object_link'><a href="../../../Servus.html" title="Servus (module)">Servus</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../../Support.html" title="Servus::Support (module)">Support</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors.html" title="Servus::Support::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors/ServiceError.html" title="Servus::Support::Errors::ServiceError (class)">ServiceError</a></span></span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
317
+ <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='lbrace'>{</span>
318
+ <span class='label'>errors:</span> <span class='id identifier rubyid_errors'>errors</span><span class='comma'>,</span>
319
+ <span class='label'>error_type:</span> <span class='id identifier rubyid_use'>use</span><span class='comma'>,</span>
320
+ <span class='label'>handler:</span> <span class='id identifier rubyid_block'>block</span>
321
+ <span class='rbrace'>}</span>
322
+
323
+ <span class='comment'># Add to rescuable_configs array
324
+ </span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_rescuable_configs'>rescuable_configs</span> <span class='op'>=</span> <span class='id identifier rubyid_rescuable_configs'>rescuable_configs</span> <span class='op'>+</span> <span class='lbracket'>[</span><span class='id identifier rubyid_config'>config</span><span class='rbracket'>]</span>
325
+ <span class='kw'>end</span></pre>
326
+ </td>
327
+ </tr>
328
+ </table>
329
+ </div>
330
+
331
+ </div>
332
+
333
+ </div>
334
+
335
+ <div id="footer">
336
+ Generated on Fri Nov 21 00:33:23 2025 by
337
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
338
+ 0.9.37 (ruby-3.4.4).
339
+ </div>
340
+
341
+ </div>
342
+ </body>
343
+ </html>