restforce 4.2.2 → 5.0.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +9 -9
  3. data/.github/ISSUE_TEMPLATE/unhandled-salesforce-error.md +17 -0
  4. data/.rubocop.yml +4 -3
  5. data/CHANGELOG.md +46 -0
  6. data/CONTRIBUTING.md +21 -1
  7. data/Dockerfile +31 -0
  8. data/Gemfile +0 -1
  9. data/README.md +43 -19
  10. data/UPGRADING.md +38 -0
  11. data/docker-compose.yml +7 -0
  12. data/lib/restforce.rb +4 -7
  13. data/lib/restforce/collection.rb +7 -2
  14. data/lib/restforce/concerns/api.rb +1 -1
  15. data/lib/restforce/concerns/caching.rb +7 -0
  16. data/lib/restforce/concerns/picklists.rb +1 -1
  17. data/lib/restforce/concerns/streaming.rb +1 -3
  18. data/lib/restforce/config.rb +4 -1
  19. data/lib/restforce/error_code.rb +617 -0
  20. data/lib/restforce/file_part.rb +24 -0
  21. data/lib/restforce/mash.rb +7 -2
  22. data/lib/restforce/middleware.rb +2 -0
  23. data/lib/restforce/middleware/caching.rb +1 -1
  24. data/lib/restforce/middleware/logger.rb +3 -2
  25. data/lib/restforce/middleware/raise_error.rb +3 -4
  26. data/lib/restforce/version.rb +1 -1
  27. data/restforce.gemspec +12 -12
  28. data/spec/integration/abstract_client_spec.rb +16 -4
  29. data/spec/spec_helper.rb +14 -1
  30. data/spec/support/fixture_helpers.rb +1 -3
  31. data/spec/unit/collection_spec.rb +18 -0
  32. data/spec/unit/concerns/caching_spec.rb +26 -0
  33. data/spec/unit/concerns/connection_spec.rb +2 -2
  34. data/spec/unit/error_code_spec.rb +61 -0
  35. data/spec/unit/middleware/authentication_spec.rb +11 -5
  36. data/spec/unit/middleware/raise_error_spec.rb +9 -0
  37. data/spec/unit/signed_request_spec.rb +1 -1
  38. metadata +34 -41
  39. data/lib/restforce/upload_io.rb +0 -9
@@ -15,6 +15,13 @@ module Restforce
15
15
  options.delete(:use_cache)
16
16
  end
17
17
 
18
+ def with_caching
19
+ options[:use_cache] = true
20
+ yield
21
+ ensure
22
+ options[:use_cache] = false
23
+ end
24
+
18
25
  private
19
26
 
20
27
  # Internal: Cache to use for the caching middleware
@@ -35,7 +35,7 @@ module Restforce
35
35
  @valid_for = options.delete(:valid_for)
36
36
  raise "#{field} is not a dependent picklist" if @valid_for && !dependent?
37
37
 
38
- replace(picklist_values)
38
+ super(picklist_values)
39
39
  end
40
40
 
41
41
  private
@@ -95,9 +95,7 @@ module Restforce
95
95
 
96
96
  def replay_id(channel)
97
97
  handler = @replay_handlers[channel]
98
- if handler.is_a?(Integer)
99
- handler # treat it as a scalar
100
- elsif handler.respond_to?(:[])
98
+ if handler.respond_to?(:[]) && !handler.is_a?(Integer)
101
99
  # Ask for the latest replayId for this channel
102
100
  handler[channel]
103
101
  else
@@ -151,11 +151,14 @@ module Restforce
151
151
  option :request_headers
152
152
 
153
153
  # Set a logger for when Restforce.log is set to true, defaulting to STDOUT
154
- option :logger, default: ::Logger.new(STDOUT)
154
+ option :logger, default: ::Logger.new($stdout)
155
155
 
156
156
  # Set a log level for logging when Restforce.log is set to true, defaulting to :debug
157
157
  option :log_level, default: :debug
158
158
 
159
+ # Set use_cache to false to opt in to caching with client.with_caching
160
+ option :use_cache, default: true
161
+
159
162
  def options
160
163
  self.class.options
161
164
  end
@@ -0,0 +1,617 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Restforce
4
+ module ErrorCode
5
+ GITHUB_ISSUE_URL = "https://github.com/restforce/restforce/issues/new?template=" \
6
+ "unhandled-salesforce-error.md&title=Unhandled+Salesforce+error%3A+%3Cinsert+" \
7
+ "error+code+here%3E"
8
+
9
+ # We define all of the known errors returned by Salesforce based on the
10
+ # documentation at
11
+ # https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_calls_concepts_core_data_objects.htm#statuscode
12
+ # Previously, these were defined dynamically at runtime using `Module.const_set`. Now
13
+ # we define them up-front.
14
+ # It is possible that we will be missing some errors, so we will handle this in
15
+ # at least a semi-graceful manner.
16
+ class AllOrNoneOperationRolledBack < ResponseError; end
17
+
18
+ class AlreadyInProcess < ResponseError; end
19
+
20
+ class ApiCurrentlyDisabled < ResponseError; end
21
+
22
+ class AssigneeTypeRequired < ResponseError; end
23
+
24
+ class BadCustomEntityParentDomain < ResponseError; end
25
+
26
+ class BccNotAllowedIfBccComplianceEnabled < ResponseError; end
27
+
28
+ class BccSelfNotAllowedIfBccComplianceEnabled < ResponseError; end
29
+
30
+ class CannotCascadeProductActive < ResponseError; end
31
+
32
+ class CannotChangeFieldTypeOfApexReferencedField < ResponseError; end
33
+
34
+ class CannotCreateAnotherManagedPackage < ResponseError; end
35
+
36
+ class CannotDeactivateDivision < ResponseError; end
37
+
38
+ class CannotDeleteLastDatedConversionRate < ResponseError; end
39
+
40
+ class CannotDeleteManagedObject < ResponseError; end
41
+
42
+ class CannotDisableLastAdmin < ResponseError; end
43
+
44
+ class CannotEnableIpRestrictRequests < ResponseError; end
45
+
46
+ class CannotInsertUpdateActivateEntity < ResponseError; end
47
+
48
+ class CannotModifyManagedObject < ResponseError; end
49
+
50
+ class CannotRenameApexReferencedField < ResponseError; end
51
+
52
+ class CannotRenameApexReferencedObject < ResponseError; end
53
+
54
+ class CannotReparentRecord < ResponseError; end
55
+
56
+ class CannotResolveName < ResponseError; end
57
+
58
+ class CannotUpdateConvertedLead < ResponseError; end
59
+
60
+ class CantDisableCorpCurrency < ResponseError; end
61
+
62
+ class CantUnsetCorpCurrency < ResponseError; end
63
+
64
+ class ChildShareFailsParent < ResponseError; end
65
+
66
+ class CircularDependency < ResponseError; end
67
+
68
+ class CommunityNotAccessible < ResponseError; end
69
+
70
+ class CustomClobFieldLimitExceeded < ResponseError; end
71
+
72
+ class CustomEntityOrFieldLimit < ResponseError; end
73
+
74
+ class CustomFieldIndexLimitExceeded < ResponseError; end
75
+
76
+ class CustomIndexExists < ResponseError; end
77
+
78
+ class CustomLinkLimitExceeded < ResponseError; end
79
+
80
+ class CustomMetadataLimitExceeded < ResponseError; end
81
+
82
+ class CustomSettingsLimitExceeded < ResponseError; end
83
+
84
+ class CustomTabLimitExceeded < ResponseError; end
85
+
86
+ class DeleteFailed < ResponseError; end
87
+
88
+ class DependencyExists < ResponseError; end
89
+
90
+ class DuplicateCaseSolution < ResponseError; end
91
+
92
+ class DuplicateCustomEntityDefinition < ResponseError; end
93
+
94
+ class DuplicateCustomTabMotif < ResponseError; end
95
+
96
+ class DuplicateDeveloperName < ResponseError; end
97
+
98
+ class DuplicatesDetected < ResponseError; end
99
+
100
+ class DuplicateExternalId < ResponseError; end
101
+
102
+ class DuplicateMasterLabel < ResponseError; end
103
+
104
+ class DuplicateSenderDisplayName < ResponseError; end
105
+
106
+ class DuplicateUsername < ResponseError; end
107
+
108
+ class DuplicateValue < ResponseError; end
109
+
110
+ class EmailAddressBounced < ResponseError; end
111
+
112
+ class EmailNotProcessedDueToPriorError < ResponseError; end
113
+
114
+ class EmailOptedOut < ResponseError; end
115
+
116
+ class EmailTemplateFormulaError < ResponseError; end
117
+
118
+ class EmailTemplateMergefieldAccessError < ResponseError; end
119
+
120
+ class EmailTemplateMergefieldError < ResponseError; end
121
+
122
+ class EmailTemplateMergefieldValueError < ResponseError; end
123
+
124
+ class EmailTemplateProcessingError < ResponseError; end
125
+
126
+ class EmptyScontrolFileName < ResponseError; end
127
+
128
+ class EntityFailedIflastmodifiedOnUpdate < ResponseError; end
129
+
130
+ class EntityIsArchived < ResponseError; end
131
+
132
+ class EntityIsDeleted < ResponseError; end
133
+
134
+ class EntityIsLocked < ResponseError; end
135
+
136
+ class EnvironmentHubMembershipConflict < ResponseError; end
137
+
138
+ class ErrorInMailer < ResponseError; end
139
+
140
+ class ExceededMaxSemijoinSubselects < ResponseError; end
141
+
142
+ class FailedActivation < ResponseError; end
143
+
144
+ class FieldCustomValidationException < ResponseError; end
145
+
146
+ class FieldFilterValidationException < ResponseError; end
147
+
148
+ class FieldIntegrityException < ResponseError; end
149
+
150
+ class FilteredLookupLimitExceeded < ResponseError; end
151
+
152
+ class Forbidden < ResponseError; end
153
+
154
+ class HtmlFileUploadNotAllowed < ResponseError; end
155
+
156
+ class IllegalQueryParameterValue < ResponseError; end
157
+
158
+ class ImageTooLarge < ResponseError; end
159
+
160
+ class InactiveOwnerOrUser < ResponseError; end
161
+
162
+ class InsertUpdateDeleteNotAllowedDuringMaintenance < ResponseError; end
163
+
164
+ class InsufficientAccessOnCrossReferenceEntity < ResponseError; end
165
+
166
+ class InsufficientAccessOrReadonly < ResponseError; end
167
+
168
+ class InvalidAccessLevel < ResponseError; end
169
+
170
+ class InvalidArgumentType < ResponseError; end
171
+
172
+ class InvalidAssigneeType < ResponseError; end
173
+
174
+ class InvalidAssignmentRule < ResponseError; end
175
+
176
+ class InvalidBatchOperation < ResponseError; end
177
+
178
+ class InvalidContentType < ResponseError; end
179
+
180
+ class InvalidCreditCardInfo < ResponseError; end
181
+
182
+ class InvalidCrossReferenceKey < ResponseError; end
183
+
184
+ class InvalidCrossReferenceTypeForField < ResponseError; end
185
+
186
+ class InvalidCurrencyConvRate < ResponseError; end
187
+
188
+ class InvalidCurrencyCorpRate < ResponseError; end
189
+
190
+ class InvalidCurrencyIso < ResponseError; end
191
+
192
+ class InvalidEmailAddress < ResponseError; end
193
+
194
+ class InvalidEmptyKeyOwner < ResponseError; end
195
+
196
+ class InvalidEventSubscription < ResponseError; end
197
+
198
+ class InvalidField < ResponseError; end
199
+
200
+ class InvalidFieldForInsertUpdate < ResponseError; end
201
+
202
+ class InvalidFieldWhenUsingTemplate < ResponseError; end
203
+
204
+ class InvalidFilterAction < ResponseError; end
205
+
206
+ class InvalidIdField < ResponseError; end
207
+
208
+ class InvalidInetAddress < ResponseError; end
209
+
210
+ class InvalidLineitemCloneState < ResponseError; end
211
+
212
+ class InvalidMasterOrTranslatedSolution < ResponseError; end
213
+
214
+ class InvalidMessageIdReference < ResponseError; end
215
+
216
+ class InvalidOperation < ResponseError; end
217
+
218
+ class InvalidOperationWithExpiredPassword < ResponseError; end
219
+
220
+ class InvalidOperator < ResponseError; end
221
+
222
+ class InvalidOrNullForRestrictedPicklist < ResponseError; end
223
+
224
+ class InvalidQueryFilterOperator < ResponseError; end
225
+
226
+ class InvalidQueryLocator < ResponseError; end
227
+
228
+ class InvalidPartnerNetworkStatus < ResponseError; end
229
+
230
+ class InvalidPersonAccountOperation < ResponseError; end
231
+
232
+ class InvalidReadOnlyUserDml < ResponseError; end
233
+
234
+ class InvalidSaveAsActivityFlag < ResponseError; end
235
+
236
+ class InvalidSessionId < ResponseError; end
237
+
238
+ class InvalidStatus < ResponseError; end
239
+
240
+ class InvalidType < ResponseError; end
241
+
242
+ class InvalidTypeForOperation < ResponseError; end
243
+
244
+ class InvalidTypeOnFieldInRecord < ResponseError; end
245
+
246
+ class IpRangeLimitExceeded < ResponseError; end
247
+
248
+ class JigsawImportLimitExceeded < ResponseError; end
249
+
250
+ class JsonParserError < ResponseError; end
251
+
252
+ class LicenseLimitExceeded < ResponseError; end
253
+
254
+ class LightPortalUserException < ResponseError; end
255
+
256
+ class LimitExceeded < ResponseError; end
257
+
258
+ class LoginChallengeIssued < ResponseError; end
259
+
260
+ class LoginChallengePending < ResponseError; end
261
+
262
+ class LoginMustUseSecurityToken < ResponseError; end
263
+
264
+ class MalformedId < ResponseError; end
265
+
266
+ class MalformedQuery < ResponseError; end
267
+
268
+ class ManagerNotDefined < ResponseError; end
269
+
270
+ class MassmailRetryLimitExceeded < ResponseError; end
271
+
272
+ class MassMailLimitExceeded < ResponseError; end
273
+
274
+ class MaximumCcemailsExceeded < ResponseError; end
275
+
276
+ class MaximumDashboardComponentsExceeded < ResponseError; end
277
+
278
+ class MaximumHierarchyLevelsReached < ResponseError; end
279
+
280
+ class MaximumSizeOfAttachment < ResponseError; end
281
+
282
+ class MaximumSizeOfDocument < ResponseError; end
283
+
284
+ class MaxActionsPerRuleExceeded < ResponseError; end
285
+
286
+ class MaxActiveRulesExceeded < ResponseError; end
287
+
288
+ class MaxApprovalStepsExceeded < ResponseError; end
289
+
290
+ class MaxFormulasPerRuleExceeded < ResponseError; end
291
+
292
+ class MaxRulesExceeded < ResponseError; end
293
+
294
+ class MaxRuleEntriesExceeded < ResponseError; end
295
+
296
+ class MaxTaskDescriptionExceeded < ResponseError; end
297
+
298
+ class MaxTmRulesExceeded < ResponseError; end
299
+
300
+ class MaxTmRuleItemsExceeded < ResponseError; end
301
+
302
+ class MergeFailed < ResponseError; end
303
+
304
+ class MissingArgument < ResponseError; end
305
+
306
+ class NonuniqueShippingAddress < ResponseError; end
307
+
308
+ class NoApplicableProcess < ResponseError; end
309
+
310
+ class NoAttachmentPermission < ResponseError; end
311
+
312
+ class NoInactiveDivisionMembers < ResponseError; end
313
+
314
+ class NoMassMailPermission < ResponseError; end
315
+
316
+ class NumberOutsideValidRange < ResponseError; end
317
+
318
+ class NumHistoryFieldsBySobjectExceeded < ResponseError; end
319
+
320
+ class OpWithInvalidUserTypeException < ResponseError; end
321
+
322
+ class OptedOutOfMassMail < ResponseError; end
323
+
324
+ class PackageLicenseRequired < ResponseError; end
325
+
326
+ class PlatformEventEncryptionError < ResponseError; end
327
+
328
+ class PlatformEventPublishingUnavailable < ResponseError; end
329
+
330
+ class PlatformEventPublishFailed < ResponseError; end
331
+
332
+ class PortalUserAlreadyExistsForContact < ResponseError; end
333
+
334
+ class PrivateContactOnAsset < ResponseError; end
335
+
336
+ class RecordInUseByWorkflow < ResponseError; end
337
+
338
+ class RequestLimitExceeded < ResponseError; end
339
+
340
+ class RequestRunningTooLong < ResponseError; end
341
+
342
+ class RequiredFieldMissing < ResponseError; end
343
+
344
+ class SelfReferenceFromTrigger < ResponseError; end
345
+
346
+ class ServerUnavailable < ResponseError; end
347
+
348
+ class ShareNeededForChildOwner < ResponseError; end
349
+
350
+ class SingleEmailLimitExceeded < ResponseError; end
351
+
352
+ class StandardPriceNotDefined < ResponseError; end
353
+
354
+ class StorageLimitExceeded < ResponseError; end
355
+
356
+ class StringTooLong < ResponseError; end
357
+
358
+ class TabsetLimitExceeded < ResponseError; end
359
+
360
+ class TemplateNotActive < ResponseError; end
361
+
362
+ class TerritoryRealignInProgress < ResponseError; end
363
+
364
+ class TextDataOutsideSupportedCharset < ResponseError; end
365
+
366
+ class TooManyApexRequests < ResponseError; end
367
+
368
+ class TooManyEnumValue < ResponseError; end
369
+
370
+ class TransferRequiresRead < ResponseError; end
371
+
372
+ class UnableToLockRow < ResponseError; end
373
+
374
+ class UnavailableRecordtypeException < ResponseError; end
375
+
376
+ class UndeleteFailed < ResponseError; end
377
+
378
+ class UnknownException < ResponseError; end
379
+
380
+ class UnspecifiedEmailAddress < ResponseError; end
381
+
382
+ class UnsupportedApexTriggerOperation < ResponseError; end
383
+
384
+ class UnverifiedSenderAddress < ResponseError; end
385
+
386
+ class WeblinkSizeLimitExceeded < ResponseError; end
387
+
388
+ class WeblinkUrlInvalid < ResponseError; end
389
+
390
+ class WrongControllerType < ResponseError; end
391
+
392
+ # Maps `errorCode`s returned from Salesforce to the exception class
393
+ # to be used for these errors
394
+ ERROR_EXCEPTION_CLASSES = {
395
+ "ALL_OR_NONE_OPERATION_ROLLED_BACK" => AllOrNoneOperationRolledBack,
396
+ "ALREADY_IN_PROCESS" => AlreadyInProcess,
397
+ "API_CURRENTLY_DISABLED" => ApiCurrentlyDisabled,
398
+ "ASSIGNEE_TYPE_REQUIRED" => AssigneeTypeRequired,
399
+ "BAD_CUSTOM_ENTITY_PARENT_DOMAIN" => BadCustomEntityParentDomain,
400
+ "BCC_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED" =>
401
+ BccNotAllowedIfBccComplianceEnabled,
402
+ "BCC_SELF_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED" =>
403
+ BccSelfNotAllowedIfBccComplianceEnabled,
404
+ "CANNOT_CASCADE_PRODUCT_ACTIVE" => CannotCascadeProductActive,
405
+ "CANNOT_CHANGE_FIELD_TYPE_OF_APEX_REFERENCED_FIELD" =>
406
+ CannotChangeFieldTypeOfApexReferencedField,
407
+ "CANNOT_CREATE_ANOTHER_MANAGED_PACKAGE" => CannotCreateAnotherManagedPackage,
408
+ "CANNOT_DEACTIVATE_DIVISION" => CannotDeactivateDivision,
409
+ "CANNOT_DELETE_LAST_DATED_CONVERSION_RATE" =>
410
+ CannotDeleteLastDatedConversionRate,
411
+ "CANNOT_DELETE_MANAGED_OBJECT" => CannotDeleteManagedObject,
412
+ "CANNOT_DISABLE_LAST_ADMIN" => CannotDisableLastAdmin,
413
+ "CANNOT_ENABLE_IP_RESTRICT_REQUESTS" => CannotEnableIpRestrictRequests,
414
+ "CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" => CannotInsertUpdateActivateEntity,
415
+ "CANNOT_MODIFY_MANAGED_OBJECT" => CannotModifyManagedObject,
416
+ "CANNOT_RENAME_APEX_REFERENCED_FIELD" => CannotRenameApexReferencedField,
417
+ "CANNOT_RENAME_APEX_REFERENCED_OBJECT" => CannotRenameApexReferencedObject,
418
+ "CANNOT_REPARENT_RECORD" => CannotReparentRecord,
419
+ "CANNOT_RESOLVE_NAME" => CannotResolveName,
420
+ "CANNOT_UPDATE_CONVERTED_LEAD" => CannotUpdateConvertedLead,
421
+ "CANT_DISABLE_CORP_CURRENCY" => CantDisableCorpCurrency,
422
+ "CANT_UNSET_CORP_CURRENCY" => CantUnsetCorpCurrency,
423
+ "CHILD_SHARE_FAILS_PARENT" => ChildShareFailsParent,
424
+ "CIRCULAR_DEPENDENCY" => CircularDependency,
425
+ "COMMUNITY_NOT_ACCESSIBLE" => CommunityNotAccessible,
426
+ "CUSTOM_CLOB_FIELD_LIMIT_EXCEEDED" => CustomClobFieldLimitExceeded,
427
+ "CUSTOM_ENTITY_OR_FIELD_LIMIT" => CustomEntityOrFieldLimit,
428
+ "CUSTOM_FIELD_INDEX_LIMIT_EXCEEDED" => CustomFieldIndexLimitExceeded,
429
+ "CUSTOM_INDEX_EXISTS" => CustomIndexExists,
430
+ "CUSTOM_LINK_LIMIT_EXCEEDED" => CustomLinkLimitExceeded,
431
+ "CUSTOM_METADATA_LIMIT_EXCEEDED" => CustomMetadataLimitExceeded,
432
+ "CUSTOM_SETTINGS_LIMIT_EXCEEDED" => CustomSettingsLimitExceeded,
433
+ "CUSTOM_TAB_LIMIT_EXCEEDED" => CustomTabLimitExceeded,
434
+ "DELETE_FAILED" => DeleteFailed,
435
+ "DEPENDENCY_EXISTS" => DependencyExists,
436
+ "DUPLICATE_CASE_SOLUTION" => DuplicateCaseSolution,
437
+ "DUPLICATE_CUSTOM_ENTITY_DEFINITION" => DuplicateCustomEntityDefinition,
438
+ "DUPLICATE_CUSTOM_TAB_MOTIF" => DuplicateCustomTabMotif,
439
+ "DUPLICATE_DEVELOPER_NAME" => DuplicateDeveloperName,
440
+ "DUPLICATES_DETECTED" => DuplicatesDetected,
441
+ "DUPLICATE_EXTERNAL_ID" => DuplicateExternalId,
442
+ "DUPLICATE_MASTER_LABEL" => DuplicateMasterLabel,
443
+ "DUPLICATE_SENDER_DISPLAY_NAME" => DuplicateSenderDisplayName,
444
+ "DUPLICATE_USERNAME" => DuplicateUsername,
445
+ "DUPLICATE_VALUE" => DuplicateValue,
446
+ "EMAIL_ADDRESS_BOUNCED" => EmailAddressBounced,
447
+ "EMAIL_NOT_PROCESSED_DUE_TO_PRIOR_ERROR" => EmailNotProcessedDueToPriorError,
448
+ "EMAIL_OPTED_OUT" => EmailOptedOut,
449
+ "EMAIL_TEMPLATE_FORMULA_ERROR" => EmailTemplateFormulaError,
450
+ "EMAIL_TEMPLATE_MERGEFIELD_ACCESS_ERROR" =>
451
+ EmailTemplateMergefieldAccessError,
452
+ "EMAIL_TEMPLATE_MERGEFIELD_ERROR" => EmailTemplateMergefieldError,
453
+ "EMAIL_TEMPLATE_MERGEFIELD_VALUE_ERROR" => EmailTemplateMergefieldValueError,
454
+ "EMAIL_TEMPLATE_PROCESSING_ERROR" => EmailTemplateProcessingError,
455
+ "EMPTY_SCONTROL_FILE_NAME" => EmptyScontrolFileName,
456
+ "ENTITY_FAILED_IFLASTMODIFIED_ON_UPDATE" =>
457
+ EntityFailedIflastmodifiedOnUpdate,
458
+ "ENTITY_IS_ARCHIVED" => EntityIsArchived,
459
+ "ENTITY_IS_DELETED" => EntityIsDeleted,
460
+ "ENTITY_IS_LOCKED" => EntityIsLocked,
461
+ "ENVIRONMENT_HUB_MEMBERSHIP_CONFLICT" => EnvironmentHubMembershipConflict,
462
+ "ERROR_IN_MAILER" => ErrorInMailer,
463
+ "EXCEEDED_MAX_SEMIJOIN_SUBSELECTS" => ExceededMaxSemijoinSubselects,
464
+ "FAILED_ACTIVATION" => FailedActivation,
465
+ "FIELD_CUSTOM_VALIDATION_EXCEPTION" => FieldCustomValidationException,
466
+ "FIELD_FILTER_VALIDATION_EXCEPTION" => FieldFilterValidationException,
467
+ "FIELD_INTEGRITY_EXCEPTION" => FieldIntegrityException,
468
+ "FILTERED_LOOKUP_LIMIT_EXCEEDED" => FilteredLookupLimitExceeded,
469
+ "FORBIDDEN" => Forbidden,
470
+ "HTML_FILE_UPLOAD_NOT_ALLOWED" => HtmlFileUploadNotAllowed,
471
+ "ILLEGAL_QUERY_PARAMETER_VALUE" => IllegalQueryParameterValue,
472
+ "IMAGE_TOO_LARGE" => ImageTooLarge,
473
+ "INACTIVE_OWNER_OR_USER" => InactiveOwnerOrUser,
474
+ "INSERT_UPDATE_DELETE_NOT_ALLOWED_DURING_MAINTENANCE" =>
475
+ InsertUpdateDeleteNotAllowedDuringMaintenance,
476
+ "INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY" =>
477
+ InsufficientAccessOnCrossReferenceEntity,
478
+ "INSUFFICIENT_ACCESS_OR_READONLY" => InsufficientAccessOrReadonly,
479
+ "INVALID_ACCESS_LEVEL" => InvalidAccessLevel,
480
+ "INVALID_ARGUMENT_TYPE" => InvalidArgumentType,
481
+ "INVALID_ASSIGNEE_TYPE" => InvalidAssigneeType,
482
+ "INVALID_ASSIGNMENT_RULE" => InvalidAssignmentRule,
483
+ "INVALID_BATCH_OPERATION" => InvalidBatchOperation,
484
+ "INVALID_CONTENT_TYPE" => InvalidContentType,
485
+ "INVALID_CREDIT_CARD_INFO" => InvalidCreditCardInfo,
486
+ "INVALID_CROSS_REFERENCE_KEY" => InvalidCrossReferenceKey,
487
+ "INVALID_CROSS_REFERENCE_TYPE_FOR_FIELD" => InvalidCrossReferenceTypeForField,
488
+ "INVALID_CURRENCY_CONV_RATE" => InvalidCurrencyConvRate,
489
+ "INVALID_CURRENCY_CORP_RATE" => InvalidCurrencyCorpRate,
490
+ "INVALID_CURRENCY_ISO" => InvalidCurrencyIso,
491
+ "INVALID_EMAIL_ADDRESS" => InvalidEmailAddress,
492
+ "INVALID_EMPTY_KEY_OWNER" => InvalidEmptyKeyOwner,
493
+ "INVALID_EVENT_SUBSCRIPTION" => InvalidEventSubscription,
494
+ "INVALID_FIELD" => InvalidField,
495
+ "INVALID_FIELD_FOR_INSERT_UPDATE" => InvalidFieldForInsertUpdate,
496
+ "INVALID_FIELD_WHEN_USING_TEMPLATE" => InvalidFieldWhenUsingTemplate,
497
+ "INVALID_FILTER_ACTION" => InvalidFilterAction,
498
+ "INVALID_ID_FIELD" => InvalidIdField,
499
+ "INVALID_INET_ADDRESS" => InvalidInetAddress,
500
+ "INVALID_LINEITEM_CLONE_STATE" => InvalidLineitemCloneState,
501
+ "INVALID_MASTER_OR_TRANSLATED_SOLUTION" => InvalidMasterOrTranslatedSolution,
502
+ "INVALID_MESSAGE_ID_REFERENCE" => InvalidMessageIdReference,
503
+ "INVALID_OPERATION" => InvalidOperation,
504
+ "INVALID_OPERATION_WITH_EXPIRED_PASSWORD" => InvalidOperationWithExpiredPassword,
505
+ "INVALID_OPERATOR" => InvalidOperator,
506
+ "INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST" =>
507
+ InvalidOrNullForRestrictedPicklist,
508
+ "INVALID_QUERY_FILTER_OPERATOR" => InvalidQueryFilterOperator,
509
+ "INVALID_QUERY_LOCATOR" => InvalidQueryLocator,
510
+ "INVALID_PARTNER_NETWORK_STATUS" => InvalidPartnerNetworkStatus,
511
+ "INVALID_PERSON_ACCOUNT_OPERATION" => InvalidPersonAccountOperation,
512
+ "INVALID_READ_ONLY_USER_DML" => InvalidReadOnlyUserDml,
513
+ "INVALID_SAVE_AS_ACTIVITY_FLAG" => InvalidSaveAsActivityFlag,
514
+ "INVALID_SESSION_ID" => InvalidSessionId,
515
+ "INVALID_STATUS" => InvalidStatus,
516
+ "INVALID_TYPE" => InvalidType,
517
+ "INVALID_TYPE_FOR_OPERATION" => InvalidTypeForOperation,
518
+ "INVALID_TYPE_ON_FIELD_IN_RECORD" => InvalidTypeOnFieldInRecord,
519
+ "IP_RANGE_LIMIT_EXCEEDED" => IpRangeLimitExceeded,
520
+ "JIGSAW_IMPORT_LIMIT_EXCEEDED" => JigsawImportLimitExceeded,
521
+ "JSON_PARSER_ERROR" => JsonParserError,
522
+ "LICENSE_LIMIT_EXCEEDED" => LicenseLimitExceeded,
523
+ "LIGHT_PORTAL_USER_EXCEPTION" => LightPortalUserException,
524
+ "LIMIT_EXCEEDED" => LimitExceeded,
525
+ "LOGIN_CHALLENGE_ISSUED" => LoginChallengeIssued,
526
+ "LOGIN_CHALLENGE_PENDING" => LoginChallengePending,
527
+ "LOGIN_MUST_USE_SECURITY_TOKEN" => LoginMustUseSecurityToken,
528
+ "MALFORMED_ID" => MalformedId,
529
+ "MALFORMED_QUERY" => MalformedQuery,
530
+ "MANAGER_NOT_DEFINED" => ManagerNotDefined,
531
+ "MASSMAIL_RETRY_LIMIT_EXCEEDED" => MassmailRetryLimitExceeded,
532
+ "MASS_MAIL_LIMIT_EXCEEDED" => MassMailLimitExceeded,
533
+ "MAXIMUM_CCEMAILS_EXCEEDED" => MaximumCcemailsExceeded,
534
+ "MAXIMUM_DASHBOARD_COMPONENTS_EXCEEDED" => MaximumDashboardComponentsExceeded,
535
+ "MAXIMUM_HIERARCHY_LEVELS_REACHED" => MaximumHierarchyLevelsReached,
536
+ "MAXIMUM_SIZE_OF_ATTACHMENT" => MaximumSizeOfAttachment,
537
+ "MAXIMUM_SIZE_OF_DOCUMENT" => MaximumSizeOfDocument,
538
+ "MAX_ACTIONS_PER_RULE_EXCEEDED" => MaxActionsPerRuleExceeded,
539
+ "MAX_ACTIVE_RULES_EXCEEDED" => MaxActiveRulesExceeded,
540
+ "MAX_APPROVAL_STEPS_EXCEEDED" => MaxApprovalStepsExceeded,
541
+ "MAX_FORMULAS_PER_RULE_EXCEEDED" => MaxFormulasPerRuleExceeded,
542
+ "MAX_RULES_EXCEEDED" => MaxRulesExceeded,
543
+ "MAX_RULE_ENTRIES_EXCEEDED" => MaxRuleEntriesExceeded,
544
+ "MAX_TASK_DESCRIPTION_EXCEEDED" => MaxTaskDescriptionExceeded,
545
+ "MAX_TM_RULES_EXCEEDED" => MaxTmRulesExceeded,
546
+ "MAX_TM_RULE_ITEMS_EXCEEDED" => MaxTmRuleItemsExceeded,
547
+ "MERGE_FAILED" => MergeFailed,
548
+ "MISSING_ARGUMENT" => MissingArgument,
549
+ "NONUNIQUE_SHIPPING_ADDRESS" => NonuniqueShippingAddress,
550
+ "NO_APPLICABLE_PROCESS" => NoApplicableProcess,
551
+ "NO_ATTACHMENT_PERMISSION" => NoAttachmentPermission,
552
+ "NO_INACTIVE_DIVISION_MEMBERS" => NoInactiveDivisionMembers,
553
+ "NO_MASS_MAIL_PERMISSION" => NoMassMailPermission,
554
+ "NUMBER_OUTSIDE_VALID_RANGE" => NumberOutsideValidRange,
555
+ "NUM_HISTORY_FIELDS_BY_SOBJECT_EXCEEDED" => NumHistoryFieldsBySobjectExceeded,
556
+ "OP_WITH_INVALID_USER_TYPE_EXCEPTION" => OpWithInvalidUserTypeException,
557
+ "OPTED_OUT_OF_MASS_MAIL" => OptedOutOfMassMail,
558
+ "PACKAGE_LICENSE_REQUIRED" => PackageLicenseRequired,
559
+ "PLATFORM_EVENT_ENCRYPTION_ERROR" => PlatformEventEncryptionError,
560
+ "PLATFORM_EVENT_PUBLISHING_UNAVAILABLE" => PlatformEventPublishingUnavailable,
561
+ "PLATFORM_EVENT_PUBLISH_FAILED" => PlatformEventPublishFailed,
562
+ "PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT" => PortalUserAlreadyExistsForContact,
563
+ "PRIVATE_CONTACT_ON_ASSET" => PrivateContactOnAsset,
564
+ "RECORD_IN_USE_BY_WORKFLOW" => RecordInUseByWorkflow,
565
+ "REQUEST_LIMIT_EXCEEDED" => RequestLimitExceeded,
566
+ "REQUEST_RUNNING_TOO_LONG" => RequestRunningTooLong,
567
+ "REQUIRED_FIELD_MISSING" => RequiredFieldMissing,
568
+ "SELF_REFERENCE_FROM_TRIGGER" => SelfReferenceFromTrigger,
569
+ "SERVER_UNAVAILABLE" => ServerUnavailable,
570
+ "SHARE_NEEDED_FOR_CHILD_OWNER" => ShareNeededForChildOwner,
571
+ "SINGLE_EMAIL_LIMIT_EXCEEDED" => SingleEmailLimitExceeded,
572
+ "STANDARD_PRICE_NOT_DEFINED" => StandardPriceNotDefined,
573
+ "STORAGE_LIMIT_EXCEEDED" => StorageLimitExceeded,
574
+ "STRING_TOO_LONG" => StringTooLong,
575
+ "TABSET_LIMIT_EXCEEDED" => TabsetLimitExceeded,
576
+ "TEMPLATE_NOT_ACTIVE" => TemplateNotActive,
577
+ "TERRITORY_REALIGN_IN_PROGRESS" => TerritoryRealignInProgress,
578
+ "TEXT_DATA_OUTSIDE_SUPPORTED_CHARSET" => TextDataOutsideSupportedCharset,
579
+ "TOO_MANY_APEX_REQUESTS" => TooManyApexRequests,
580
+ "TOO_MANY_ENUM_VALUE" => TooManyEnumValue,
581
+ "TRANSFER_REQUIRES_READ" => TransferRequiresRead,
582
+ "UNABLE_TO_LOCK_ROW" => UnableToLockRow,
583
+ "UNAVAILABLE_RECORDTYPE_EXCEPTION" => UnavailableRecordtypeException,
584
+ "UNDELETE_FAILED" => UndeleteFailed,
585
+ "UNKNOWN_EXCEPTION" => UnknownException,
586
+ "UNSPECIFIED_EMAIL_ADDRESS" => UnspecifiedEmailAddress,
587
+ "UNSUPPORTED_APEX_TRIGGER_OPERATION" => UnsupportedApexTriggerOperation,
588
+ "UNVERIFIED_SENDER_ADDRESS" => UnverifiedSenderAddress,
589
+ "WEBLINK_SIZE_LIMIT_EXCEEDED" => WeblinkSizeLimitExceeded,
590
+ "WEBLINK_URL_INVALID" => WeblinkUrlInvalid,
591
+ "WRONG_CONTROLLER_TYPE" => WrongControllerType
592
+ }.freeze
593
+
594
+ def self.get_exception_class(error_code)
595
+ ERROR_EXCEPTION_CLASSES.fetch(error_code) do |_|
596
+ warn "[restforce] An unrecognised error code, `#{error_code}` has been " \
597
+ "received from Salesforce. Instead of raising an error-specific exception, " \
598
+ "we'll raise a generic `ResponseError`. Please report this missing error code" \
599
+ " on GitHub at <#{GITHUB_ISSUE_URL}>."
600
+
601
+ # If we've received an unexpected error where we don't have a specific
602
+ # class defined, we can return a generic ResponseError instead
603
+ ResponseError
604
+ end
605
+ end
606
+
607
+ def self.const_missing(constant_name)
608
+ warn "[restforce] You're referring to a Restforce error that isn't defined, " \
609
+ "`#{name}::#{constant_name}` (for example by trying to `rescue` it). This might " \
610
+ "be our fault - we've recently made some changes to how errors are defined. If " \
611
+ "you're sure that this is a valid Salesforce error, then please create an " \
612
+ "issue on GitHub at <#{GITHUB_ISSUE_URL}>."
613
+
614
+ super(constant_name)
615
+ end
616
+ end
617
+ end