restforce 4.2.1 → 5.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +9 -9
- data/.github/ISSUE_TEMPLATE/unhandled-salesforce-error.md +17 -0
- data/.rubocop.yml +4 -3
- data/CHANGELOG.md +41 -0
- data/CONTRIBUTING.md +21 -1
- data/Dockerfile +31 -0
- data/Gemfile +0 -1
- data/README.md +43 -19
- data/UPGRADING.md +38 -0
- data/docker-compose.yml +7 -0
- data/lib/restforce.rb +4 -7
- data/lib/restforce/collection.rb +7 -2
- data/lib/restforce/concerns/api.rb +1 -1
- data/lib/restforce/concerns/caching.rb +7 -0
- data/lib/restforce/concerns/picklists.rb +1 -1
- data/lib/restforce/config.rb +4 -1
- data/lib/restforce/error_code.rb +418 -0
- data/lib/restforce/file_part.rb +24 -0
- data/lib/restforce/mash.rb +8 -3
- data/lib/restforce/middleware.rb +2 -0
- data/lib/restforce/middleware/caching.rb +1 -1
- data/lib/restforce/middleware/logger.rb +3 -2
- data/lib/restforce/middleware/raise_error.rb +3 -4
- data/lib/restforce/version.rb +1 -1
- data/restforce.gemspec +11 -12
- data/spec/integration/abstract_client_spec.rb +16 -4
- data/spec/spec_helper.rb +14 -1
- data/spec/support/fixture_helpers.rb +1 -3
- data/spec/unit/collection_spec.rb +18 -0
- data/spec/unit/concerns/caching_spec.rb +26 -0
- data/spec/unit/concerns/connection_spec.rb +2 -2
- data/spec/unit/error_code_spec.rb +61 -0
- data/spec/unit/mash_spec.rb +5 -0
- data/spec/unit/middleware/authentication_spec.rb +7 -5
- data/spec/unit/middleware/raise_error_spec.rb +9 -0
- data/spec/unit/signed_request_spec.rb +1 -1
- metadata +31 -38
- data/lib/restforce/upload_io.rb +0 -9
data/lib/restforce/config.rb
CHANGED
@@ -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(
|
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,418 @@
|
|
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
|
+
class AlreadyInProcess < ResponseError; end
|
18
|
+
class ApiCurrentlyDisabled < ResponseError; end
|
19
|
+
class AssigneeTypeRequired < ResponseError; end
|
20
|
+
class BadCustomEntityParentDomain < ResponseError; end
|
21
|
+
class BccNotAllowedIfBccComplianceEnabled < ResponseError; end
|
22
|
+
class BccSelfNotAllowedIfBccComplianceEnabled < ResponseError; end
|
23
|
+
class CannotCascadeProductActive < ResponseError; end
|
24
|
+
class CannotChangeFieldTypeOfApexReferencedField < ResponseError; end
|
25
|
+
class CannotCreateAnotherManagedPackage < ResponseError; end
|
26
|
+
class CannotDeactivateDivision < ResponseError; end
|
27
|
+
class CannotDeleteLastDatedConversionRate < ResponseError; end
|
28
|
+
class CannotDeleteManagedObject < ResponseError; end
|
29
|
+
class CannotDisableLastAdmin < ResponseError; end
|
30
|
+
class CannotEnableIpRestrictRequests < ResponseError; end
|
31
|
+
class CannotInsertUpdateActivateEntity < ResponseError; end
|
32
|
+
class CannotModifyManagedObject < ResponseError; end
|
33
|
+
class CannotRenameApexReferencedField < ResponseError; end
|
34
|
+
class CannotRenameApexReferencedObject < ResponseError; end
|
35
|
+
class CannotReparentRecord < ResponseError; end
|
36
|
+
class CannotResolveName < ResponseError; end
|
37
|
+
class CannotUpdateConvertedLead < ResponseError; end
|
38
|
+
class CantDisableCorpCurrency < ResponseError; end
|
39
|
+
class CantUnsetCorpCurrency < ResponseError; end
|
40
|
+
class ChildShareFailsParent < ResponseError; end
|
41
|
+
class CircularDependency < ResponseError; end
|
42
|
+
class CommunityNotAccessible < ResponseError; end
|
43
|
+
class CustomClobFieldLimitExceeded < ResponseError; end
|
44
|
+
class CustomEntityOrFieldLimit < ResponseError; end
|
45
|
+
class CustomFieldIndexLimitExceeded < ResponseError; end
|
46
|
+
class CustomIndexExists < ResponseError; end
|
47
|
+
class CustomLinkLimitExceeded < ResponseError; end
|
48
|
+
class CustomMetadataLimitExceeded < ResponseError; end
|
49
|
+
class CustomSettingsLimitExceeded < ResponseError; end
|
50
|
+
class CustomTabLimitExceeded < ResponseError; end
|
51
|
+
class DeleteFailed < ResponseError; end
|
52
|
+
class DependencyExists < ResponseError; end
|
53
|
+
class DuplicateCaseSolution < ResponseError; end
|
54
|
+
class DuplicateCustomEntityDefinition < ResponseError; end
|
55
|
+
class DuplicateCustomTabMotif < ResponseError; end
|
56
|
+
class DuplicateDeveloperName < ResponseError; end
|
57
|
+
class DuplicatesDetected < ResponseError; end
|
58
|
+
class DuplicateExternalId < ResponseError; end
|
59
|
+
class DuplicateMasterLabel < ResponseError; end
|
60
|
+
class DuplicateSenderDisplayName < ResponseError; end
|
61
|
+
class DuplicateUsername < ResponseError; end
|
62
|
+
class DuplicateValue < ResponseError; end
|
63
|
+
class EmailAddressBounced < ResponseError; end
|
64
|
+
class EmailNotProcessedDueToPriorError < ResponseError; end
|
65
|
+
class EmailOptedOut < ResponseError; end
|
66
|
+
class EmailTemplateFormulaError < ResponseError; end
|
67
|
+
class EmailTemplateMergefieldAccessError < ResponseError; end
|
68
|
+
class EmailTemplateMergefieldError < ResponseError; end
|
69
|
+
class EmailTemplateMergefieldValueError < ResponseError; end
|
70
|
+
class EmailTemplateProcessingError < ResponseError; end
|
71
|
+
class EmptyScontrolFileName < ResponseError; end
|
72
|
+
class EntityFailedIflastmodifiedOnUpdate < ResponseError; end
|
73
|
+
class EntityIsArchived < ResponseError; end
|
74
|
+
class EntityIsDeleted < ResponseError; end
|
75
|
+
class EntityIsLocked < ResponseError; end
|
76
|
+
class EnvironmentHubMembershipConflict < ResponseError; end
|
77
|
+
class ErrorInMailer < ResponseError; end
|
78
|
+
class ExceededMaxSemijoinSubselects < ResponseError; end
|
79
|
+
class FailedActivation < ResponseError; end
|
80
|
+
class FieldCustomValidationException < ResponseError; end
|
81
|
+
class FieldFilterValidationException < ResponseError; end
|
82
|
+
class FilteredLookupLimitExceeded < ResponseError; end
|
83
|
+
class HtmlFileUploadNotAllowed < ResponseError; end
|
84
|
+
class ImageTooLarge < ResponseError; end
|
85
|
+
class InactiveOwnerOrUser < ResponseError; end
|
86
|
+
class InsertUpdateDeleteNotAllowedDuringMaintenance < ResponseError; end
|
87
|
+
class InsufficientAccessOnCrossReferenceEntity < ResponseError; end
|
88
|
+
class InsufficientAccessOrReadonly < ResponseError; end
|
89
|
+
class InvalidAccessLevel < ResponseError; end
|
90
|
+
class InvalidArgumentType < ResponseError; end
|
91
|
+
class InvalidAssigneeType < ResponseError; end
|
92
|
+
class InvalidAssignmentRule < ResponseError; end
|
93
|
+
class InvalidBatchOperation < ResponseError; end
|
94
|
+
class InvalidContentType < ResponseError; end
|
95
|
+
class InvalidCreditCardInfo < ResponseError; end
|
96
|
+
class InvalidCrossReferenceKey < ResponseError; end
|
97
|
+
class InvalidCrossReferenceTypeForField < ResponseError; end
|
98
|
+
class InvalidCurrencyConvRate < ResponseError; end
|
99
|
+
class InvalidCurrencyCorpRate < ResponseError; end
|
100
|
+
class InvalidCurrencyIso < ResponseError; end
|
101
|
+
class InvalidEmailAddress < ResponseError; end
|
102
|
+
class InvalidEmptyKeyOwner < ResponseError; end
|
103
|
+
class InvalidEventSubscription < ResponseError; end
|
104
|
+
class InvalidField < ResponseError; end
|
105
|
+
class InvalidFieldForInsertUpdate < ResponseError; end
|
106
|
+
class InvalidFieldWhenUsingTemplate < ResponseError; end
|
107
|
+
class InvalidFilterAction < ResponseError; end
|
108
|
+
class InvalidIdField < ResponseError; end
|
109
|
+
class InvalidInetAddress < ResponseError; end
|
110
|
+
class InvalidLineitemCloneState < ResponseError; end
|
111
|
+
class InvalidMasterOrTranslatedSolution < ResponseError; end
|
112
|
+
class InvalidMessageIdReference < ResponseError; end
|
113
|
+
class InvalidOperation < ResponseError; end
|
114
|
+
class InvalidOperator < ResponseError; end
|
115
|
+
class InvalidOrNullForRestrictedPicklist < ResponseError; end
|
116
|
+
class InvalidQueryFilterOperator < ResponseError; end
|
117
|
+
class InvalidPartnerNetworkStatus < ResponseError; end
|
118
|
+
class InvalidPersonAccountOperation < ResponseError; end
|
119
|
+
class InvalidReadOnlyUserDml < ResponseError; end
|
120
|
+
class InvalidSaveAsActivityFlag < ResponseError; end
|
121
|
+
class InvalidSessionId < ResponseError; end
|
122
|
+
class InvalidStatus < ResponseError; end
|
123
|
+
class InvalidType < ResponseError; end
|
124
|
+
class InvalidTypeForOperation < ResponseError; end
|
125
|
+
class InvalidTypeOnFieldInRecord < ResponseError; end
|
126
|
+
class IpRangeLimitExceeded < ResponseError; end
|
127
|
+
class JigsawImportLimitExceeded < ResponseError; end
|
128
|
+
class LicenseLimitExceeded < ResponseError; end
|
129
|
+
class LightPortalUserException < ResponseError; end
|
130
|
+
class LimitExceeded < ResponseError; end
|
131
|
+
class LoginChallengeIssued < ResponseError; end
|
132
|
+
class LoginChallengePending < ResponseError; end
|
133
|
+
class LoginMustUseSecurityToken < ResponseError; end
|
134
|
+
class MalformedId < ResponseError; end
|
135
|
+
class MalformedQuery < ResponseError; end
|
136
|
+
class ManagerNotDefined < ResponseError; end
|
137
|
+
class MassmailRetryLimitExceeded < ResponseError; end
|
138
|
+
class MassMailLimitExceeded < ResponseError; end
|
139
|
+
class MaximumCcemailsExceeded < ResponseError; end
|
140
|
+
class MaximumDashboardComponentsExceeded < ResponseError; end
|
141
|
+
class MaximumHierarchyLevelsReached < ResponseError; end
|
142
|
+
class MaximumSizeOfAttachment < ResponseError; end
|
143
|
+
class MaximumSizeOfDocument < ResponseError; end
|
144
|
+
class MaxActionsPerRuleExceeded < ResponseError; end
|
145
|
+
class MaxActiveRulesExceeded < ResponseError; end
|
146
|
+
class MaxApprovalStepsExceeded < ResponseError; end
|
147
|
+
class MaxFormulasPerRuleExceeded < ResponseError; end
|
148
|
+
class MaxRulesExceeded < ResponseError; end
|
149
|
+
class MaxRuleEntriesExceeded < ResponseError; end
|
150
|
+
class MaxTaskDescriptionExceeded < ResponseError; end
|
151
|
+
class MaxTmRulesExceeded < ResponseError; end
|
152
|
+
class MaxTmRuleItemsExceeded < ResponseError; end
|
153
|
+
class MergeFailed < ResponseError; end
|
154
|
+
class MissingArgument < ResponseError; end
|
155
|
+
class NonuniqueShippingAddress < ResponseError; end
|
156
|
+
class NoApplicableProcess < ResponseError; end
|
157
|
+
class NoAttachmentPermission < ResponseError; end
|
158
|
+
class NoInactiveDivisionMembers < ResponseError; end
|
159
|
+
class NoMassMailPermission < ResponseError; end
|
160
|
+
class NumberOutsideValidRange < ResponseError; end
|
161
|
+
class NumHistoryFieldsBySobjectExceeded < ResponseError; end
|
162
|
+
class OpWithInvalidUserTypeException < ResponseError; end
|
163
|
+
class OptedOutOfMassMail < ResponseError; end
|
164
|
+
class PackageLicenseRequired < ResponseError; end
|
165
|
+
class PlatformEventEncryptionError < ResponseError; end
|
166
|
+
class PlatformEventPublishingUnavailable < ResponseError; end
|
167
|
+
class PlatformEventPublishFailed < ResponseError; end
|
168
|
+
class PortalUserAlreadyExistsForContact < ResponseError; end
|
169
|
+
class PrivateContactOnAsset < ResponseError; end
|
170
|
+
class RecordInUseByWorkflow < ResponseError; end
|
171
|
+
class RequestLimitExceeded < ResponseError; end
|
172
|
+
class RequestRunningTooLong < ResponseError; end
|
173
|
+
class RequiredFieldMissing < ResponseError; end
|
174
|
+
class SelfReferenceFromTrigger < ResponseError; end
|
175
|
+
class ServerUnavailable < ResponseError; end
|
176
|
+
class ShareNeededForChildOwner < ResponseError; end
|
177
|
+
class SingleEmailLimitExceeded < ResponseError; end
|
178
|
+
class StandardPriceNotDefined < ResponseError; end
|
179
|
+
class StorageLimitExceeded < ResponseError; end
|
180
|
+
class StringTooLong < ResponseError; end
|
181
|
+
class TabsetLimitExceeded < ResponseError; end
|
182
|
+
class TemplateNotActive < ResponseError; end
|
183
|
+
class TerritoryRealignInProgress < ResponseError; end
|
184
|
+
class TextDataOutsideSupportedCharset < ResponseError; end
|
185
|
+
class TooManyApexRequests < ResponseError; end
|
186
|
+
class TooManyEnumValue < ResponseError; end
|
187
|
+
class TransferRequiresRead < ResponseError; end
|
188
|
+
class UnableToLockRow < ResponseError; end
|
189
|
+
class UnavailableRecordtypeException < ResponseError; end
|
190
|
+
class UndeleteFailed < ResponseError; end
|
191
|
+
class UnknownException < ResponseError; end
|
192
|
+
class UnspecifiedEmailAddress < ResponseError; end
|
193
|
+
class UnsupportedApexTriggerOperation < ResponseError; end
|
194
|
+
class UnverifiedSenderAddress < ResponseError; end
|
195
|
+
class WeblinkSizeLimitExceeded < ResponseError; end
|
196
|
+
class WeblinkUrlInvalid < ResponseError; end
|
197
|
+
class WrongControllerType < ResponseError; end
|
198
|
+
|
199
|
+
# Maps `errorCode`s returned from Salesforce to the exception class
|
200
|
+
# to be used for these errors
|
201
|
+
ERROR_EXCEPTION_CLASSES = {
|
202
|
+
"ALL_OR_NONE_OPERATION_ROLLED_BACK" => AllOrNoneOperationRolledBack,
|
203
|
+
"ALREADY_IN_PROCESS" => AlreadyInProcess,
|
204
|
+
"API_CURRENTLY_DISABLED" => ApiCurrentlyDisabled,
|
205
|
+
"ASSIGNEE_TYPE_REQUIRED" => AssigneeTypeRequired,
|
206
|
+
"BAD_CUSTOM_ENTITY_PARENT_DOMAIN" => BadCustomEntityParentDomain,
|
207
|
+
"BCC_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED" =>
|
208
|
+
BccNotAllowedIfBccComplianceEnabled,
|
209
|
+
"BCC_SELF_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED" =>
|
210
|
+
BccSelfNotAllowedIfBccComplianceEnabled,
|
211
|
+
"CANNOT_CASCADE_PRODUCT_ACTIVE" => CannotCascadeProductActive,
|
212
|
+
"CANNOT_CHANGE_FIELD_TYPE_OF_APEX_REFERENCED_FIELD" =>
|
213
|
+
CannotChangeFieldTypeOfApexReferencedField,
|
214
|
+
"CANNOT_CREATE_ANOTHER_MANAGED_PACKAGE" => CannotCreateAnotherManagedPackage,
|
215
|
+
"CANNOT_DEACTIVATE_DIVISION" => CannotDeactivateDivision,
|
216
|
+
"CANNOT_DELETE_LAST_DATED_CONVERSION_RATE" =>
|
217
|
+
CannotDeleteLastDatedConversionRate,
|
218
|
+
"CANNOT_DELETE_MANAGED_OBJECT" => CannotDeleteManagedObject,
|
219
|
+
"CANNOT_DISABLE_LAST_ADMIN" => CannotDisableLastAdmin,
|
220
|
+
"CANNOT_ENABLE_IP_RESTRICT_REQUESTS" => CannotEnableIpRestrictRequests,
|
221
|
+
"CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY" => CannotInsertUpdateActivateEntity,
|
222
|
+
"CANNOT_MODIFY_MANAGED_OBJECT" => CannotModifyManagedObject,
|
223
|
+
"CANNOT_RENAME_APEX_REFERENCED_FIELD" => CannotRenameApexReferencedField,
|
224
|
+
"CANNOT_RENAME_APEX_REFERENCED_OBJECT" => CannotRenameApexReferencedObject,
|
225
|
+
"CANNOT_REPARENT_RECORD" => CannotReparentRecord,
|
226
|
+
"CANNOT_RESOLVE_NAME" => CannotResolveName,
|
227
|
+
"CANNOT_UPDATE_CONVERTED_LEAD" => CannotUpdateConvertedLead,
|
228
|
+
"CANT_DISABLE_CORP_CURRENCY" => CantDisableCorpCurrency,
|
229
|
+
"CANT_UNSET_CORP_CURRENCY" => CantUnsetCorpCurrency,
|
230
|
+
"CHILD_SHARE_FAILS_PARENT" => ChildShareFailsParent,
|
231
|
+
"CIRCULAR_DEPENDENCY" => CircularDependency,
|
232
|
+
"COMMUNITY_NOT_ACCESSIBLE" => CommunityNotAccessible,
|
233
|
+
"CUSTOM_CLOB_FIELD_LIMIT_EXCEEDED" => CustomClobFieldLimitExceeded,
|
234
|
+
"CUSTOM_ENTITY_OR_FIELD_LIMIT" => CustomEntityOrFieldLimit,
|
235
|
+
"CUSTOM_FIELD_INDEX_LIMIT_EXCEEDED" => CustomFieldIndexLimitExceeded,
|
236
|
+
"CUSTOM_INDEX_EXISTS" => CustomIndexExists,
|
237
|
+
"CUSTOM_LINK_LIMIT_EXCEEDED" => CustomLinkLimitExceeded,
|
238
|
+
"CUSTOM_METADATA_LIMIT_EXCEEDED" => CustomMetadataLimitExceeded,
|
239
|
+
"CUSTOM_SETTINGS_LIMIT_EXCEEDED" => CustomSettingsLimitExceeded,
|
240
|
+
"CUSTOM_TAB_LIMIT_EXCEEDED" => CustomTabLimitExceeded,
|
241
|
+
"DELETE_FAILED" => DeleteFailed,
|
242
|
+
"DEPENDENCY_EXISTS" => DependencyExists,
|
243
|
+
"DUPLICATE_CASE_SOLUTION" => DuplicateCaseSolution,
|
244
|
+
"DUPLICATE_CUSTOM_ENTITY_DEFINITION" => DuplicateCustomEntityDefinition,
|
245
|
+
"DUPLICATE_CUSTOM_TAB_MOTIF" => DuplicateCustomTabMotif,
|
246
|
+
"DUPLICATE_DEVELOPER_NAME" => DuplicateDeveloperName,
|
247
|
+
"DUPLICATES_DETECTED" => DuplicatesDetected,
|
248
|
+
"DUPLICATE_EXTERNAL_ID" => DuplicateExternalId,
|
249
|
+
"DUPLICATE_MASTER_LABEL" => DuplicateMasterLabel,
|
250
|
+
"DUPLICATE_SENDER_DISPLAY_NAME" => DuplicateSenderDisplayName,
|
251
|
+
"DUPLICATE_USERNAME" => DuplicateUsername,
|
252
|
+
"DUPLICATE_VALUE" => DuplicateValue,
|
253
|
+
"EMAIL_ADDRESS_BOUNCED" => EmailAddressBounced,
|
254
|
+
"EMAIL_NOT_PROCESSED_DUE_TO_PRIOR_ERROR" => EmailNotProcessedDueToPriorError,
|
255
|
+
"EMAIL_OPTED_OUT" => EmailOptedOut,
|
256
|
+
"EMAIL_TEMPLATE_FORMULA_ERROR" => EmailTemplateFormulaError,
|
257
|
+
"EMAIL_TEMPLATE_MERGEFIELD_ACCESS_ERROR" =>
|
258
|
+
EmailTemplateMergefieldAccessError,
|
259
|
+
"EMAIL_TEMPLATE_MERGEFIELD_ERROR" => EmailTemplateMergefieldError,
|
260
|
+
"EMAIL_TEMPLATE_MERGEFIELD_VALUE_ERROR" => EmailTemplateMergefieldValueError,
|
261
|
+
"EMAIL_TEMPLATE_PROCESSING_ERROR" => EmailTemplateProcessingError,
|
262
|
+
"EMPTY_SCONTROL_FILE_NAME" => EmptyScontrolFileName,
|
263
|
+
"ENTITY_FAILED_IFLASTMODIFIED_ON_UPDATE" =>
|
264
|
+
EntityFailedIflastmodifiedOnUpdate,
|
265
|
+
"ENTITY_IS_ARCHIVED" => EntityIsArchived,
|
266
|
+
"ENTITY_IS_DELETED" => EntityIsDeleted,
|
267
|
+
"ENTITY_IS_LOCKED" => EntityIsLocked,
|
268
|
+
"ENVIRONMENT_HUB_MEMBERSHIP_CONFLICT" => EnvironmentHubMembershipConflict,
|
269
|
+
"ERROR_IN_MAILER" => ErrorInMailer,
|
270
|
+
"EXCEEDED_MAX_SEMIJOIN_SUBSELECTS" => ExceededMaxSemijoinSubselects,
|
271
|
+
"FAILED_ACTIVATION" => FailedActivation,
|
272
|
+
"FIELD_CUSTOM_VALIDATION_EXCEPTION" => FieldCustomValidationException,
|
273
|
+
"FIELD_FILTER_VALIDATION_EXCEPTION" => FieldFilterValidationException,
|
274
|
+
"FILTERED_LOOKUP_LIMIT_EXCEEDED" => FilteredLookupLimitExceeded,
|
275
|
+
"HTML_FILE_UPLOAD_NOT_ALLOWED" => HtmlFileUploadNotAllowed,
|
276
|
+
"IMAGE_TOO_LARGE" => ImageTooLarge,
|
277
|
+
"INACTIVE_OWNER_OR_USER" => InactiveOwnerOrUser,
|
278
|
+
"INSERT_UPDATE_DELETE_NOT_ALLOWED_DURING_MAINTENANCE" =>
|
279
|
+
InsertUpdateDeleteNotAllowedDuringMaintenance,
|
280
|
+
"INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY" =>
|
281
|
+
InsufficientAccessOnCrossReferenceEntity,
|
282
|
+
"INSUFFICIENT_ACCESS_OR_READONLY" => InsufficientAccessOrReadonly,
|
283
|
+
"INVALID_ACCESS_LEVEL" => InvalidAccessLevel,
|
284
|
+
"INVALID_ARGUMENT_TYPE" => InvalidArgumentType,
|
285
|
+
"INVALID_ASSIGNEE_TYPE" => InvalidAssigneeType,
|
286
|
+
"INVALID_ASSIGNMENT_RULE" => InvalidAssignmentRule,
|
287
|
+
"INVALID_BATCH_OPERATION" => InvalidBatchOperation,
|
288
|
+
"INVALID_CONTENT_TYPE" => InvalidContentType,
|
289
|
+
"INVALID_CREDIT_CARD_INFO" => InvalidCreditCardInfo,
|
290
|
+
"INVALID_CROSS_REFERENCE_KEY" => InvalidCrossReferenceKey,
|
291
|
+
"INVALID_CROSS_REFERENCE_TYPE_FOR_FIELD" => InvalidCrossReferenceTypeForField,
|
292
|
+
"INVALID_CURRENCY_CONV_RATE" => InvalidCurrencyConvRate,
|
293
|
+
"INVALID_CURRENCY_CORP_RATE" => InvalidCurrencyCorpRate,
|
294
|
+
"INVALID_CURRENCY_ISO" => InvalidCurrencyIso,
|
295
|
+
"INVALID_EMAIL_ADDRESS" => InvalidEmailAddress,
|
296
|
+
"INVALID_EMPTY_KEY_OWNER" => InvalidEmptyKeyOwner,
|
297
|
+
"INVALID_EVENT_SUBSCRIPTION" => InvalidEventSubscription,
|
298
|
+
"INVALID_FIELD" => InvalidField,
|
299
|
+
"INVALID_FIELD_FOR_INSERT_UPDATE" => InvalidFieldForInsertUpdate,
|
300
|
+
"INVALID_FIELD_WHEN_USING_TEMPLATE" => InvalidFieldWhenUsingTemplate,
|
301
|
+
"INVALID_FILTER_ACTION" => InvalidFilterAction,
|
302
|
+
"INVALID_ID_FIELD" => InvalidIdField,
|
303
|
+
"INVALID_INET_ADDRESS" => InvalidInetAddress,
|
304
|
+
"INVALID_LINEITEM_CLONE_STATE" => InvalidLineitemCloneState,
|
305
|
+
"INVALID_MASTER_OR_TRANSLATED_SOLUTION" => InvalidMasterOrTranslatedSolution,
|
306
|
+
"INVALID_MESSAGE_ID_REFERENCE" => InvalidMessageIdReference,
|
307
|
+
"INVALID_OPERATION" => InvalidOperation,
|
308
|
+
"INVALID_OPERATOR" => InvalidOperator,
|
309
|
+
"INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST" =>
|
310
|
+
InvalidOrNullForRestrictedPicklist,
|
311
|
+
"INVALID_QUERY_FILTER_OPERATOR" => InvalidQueryFilterOperator,
|
312
|
+
"INVALID_PARTNER_NETWORK_STATUS" => InvalidPartnerNetworkStatus,
|
313
|
+
"INVALID_PERSON_ACCOUNT_OPERATION" => InvalidPersonAccountOperation,
|
314
|
+
"INVALID_READ_ONLY_USER_DML" => InvalidReadOnlyUserDml,
|
315
|
+
"INVALID_SAVE_AS_ACTIVITY_FLAG" => InvalidSaveAsActivityFlag,
|
316
|
+
"INVALID_SESSION_ID" => InvalidSessionId,
|
317
|
+
"INVALID_STATUS" => InvalidStatus,
|
318
|
+
"INVALID_TYPE" => InvalidType,
|
319
|
+
"INVALID_TYPE_FOR_OPERATION" => InvalidTypeForOperation,
|
320
|
+
"INVALID_TYPE_ON_FIELD_IN_RECORD" => InvalidTypeOnFieldInRecord,
|
321
|
+
"IP_RANGE_LIMIT_EXCEEDED" => IpRangeLimitExceeded,
|
322
|
+
"JIGSAW_IMPORT_LIMIT_EXCEEDED" => JigsawImportLimitExceeded,
|
323
|
+
"LICENSE_LIMIT_EXCEEDED" => LicenseLimitExceeded,
|
324
|
+
"LIGHT_PORTAL_USER_EXCEPTION" => LightPortalUserException,
|
325
|
+
"LIMIT_EXCEEDED" => LimitExceeded,
|
326
|
+
"LOGIN_CHALLENGE_ISSUED" => LoginChallengeIssued,
|
327
|
+
"LOGIN_CHALLENGE_PENDING" => LoginChallengePending,
|
328
|
+
"LOGIN_MUST_USE_SECURITY_TOKEN" => LoginMustUseSecurityToken,
|
329
|
+
"MALFORMED_ID" => MalformedId,
|
330
|
+
"MALFORMED_QUERY" => MalformedQuery,
|
331
|
+
"MANAGER_NOT_DEFINED" => ManagerNotDefined,
|
332
|
+
"MASSMAIL_RETRY_LIMIT_EXCEEDED" => MassmailRetryLimitExceeded,
|
333
|
+
"MASS_MAIL_LIMIT_EXCEEDED" => MassMailLimitExceeded,
|
334
|
+
"MAXIMUM_CCEMAILS_EXCEEDED" => MaximumCcemailsExceeded,
|
335
|
+
"MAXIMUM_DASHBOARD_COMPONENTS_EXCEEDED" => MaximumDashboardComponentsExceeded,
|
336
|
+
"MAXIMUM_HIERARCHY_LEVELS_REACHED" => MaximumHierarchyLevelsReached,
|
337
|
+
"MAXIMUM_SIZE_OF_ATTACHMENT" => MaximumSizeOfAttachment,
|
338
|
+
"MAXIMUM_SIZE_OF_DOCUMENT" => MaximumSizeOfDocument,
|
339
|
+
"MAX_ACTIONS_PER_RULE_EXCEEDED" => MaxActionsPerRuleExceeded,
|
340
|
+
"MAX_ACTIVE_RULES_EXCEEDED" => MaxActiveRulesExceeded,
|
341
|
+
"MAX_APPROVAL_STEPS_EXCEEDED" => MaxApprovalStepsExceeded,
|
342
|
+
"MAX_FORMULAS_PER_RULE_EXCEEDED" => MaxFormulasPerRuleExceeded,
|
343
|
+
"MAX_RULES_EXCEEDED" => MaxRulesExceeded,
|
344
|
+
"MAX_RULE_ENTRIES_EXCEEDED" => MaxRuleEntriesExceeded,
|
345
|
+
"MAX_TASK_DESCRIPTION_EXCEEDED" => MaxTaskDescriptionExceeded,
|
346
|
+
"MAX_TM_RULES_EXCEEDED" => MaxTmRulesExceeded,
|
347
|
+
"MAX_TM_RULE_ITEMS_EXCEEDED" => MaxTmRuleItemsExceeded,
|
348
|
+
"MERGE_FAILED" => MergeFailed,
|
349
|
+
"MISSING_ARGUMENT" => MissingArgument,
|
350
|
+
"NONUNIQUE_SHIPPING_ADDRESS" => NonuniqueShippingAddress,
|
351
|
+
"NO_APPLICABLE_PROCESS" => NoApplicableProcess,
|
352
|
+
"NO_ATTACHMENT_PERMISSION" => NoAttachmentPermission,
|
353
|
+
"NO_INACTIVE_DIVISION_MEMBERS" => NoInactiveDivisionMembers,
|
354
|
+
"NO_MASS_MAIL_PERMISSION" => NoMassMailPermission,
|
355
|
+
"NUMBER_OUTSIDE_VALID_RANGE" => NumberOutsideValidRange,
|
356
|
+
"NUM_HISTORY_FIELDS_BY_SOBJECT_EXCEEDED" => NumHistoryFieldsBySobjectExceeded,
|
357
|
+
"OP_WITH_INVALID_USER_TYPE_EXCEPTION" => OpWithInvalidUserTypeException,
|
358
|
+
"OPTED_OUT_OF_MASS_MAIL" => OptedOutOfMassMail,
|
359
|
+
"PACKAGE_LICENSE_REQUIRED" => PackageLicenseRequired,
|
360
|
+
"PLATFORM_EVENT_ENCRYPTION_ERROR" => PlatformEventEncryptionError,
|
361
|
+
"PLATFORM_EVENT_PUBLISHING_UNAVAILABLE" => PlatformEventPublishingUnavailable,
|
362
|
+
"PLATFORM_EVENT_PUBLISH_FAILED" => PlatformEventPublishFailed,
|
363
|
+
"PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT" => PortalUserAlreadyExistsForContact,
|
364
|
+
"PRIVATE_CONTACT_ON_ASSET" => PrivateContactOnAsset,
|
365
|
+
"RECORD_IN_USE_BY_WORKFLOW" => RecordInUseByWorkflow,
|
366
|
+
"REQUEST_LIMIT_EXCEEDED" => RequestLimitExceeded,
|
367
|
+
"REQUEST_RUNNING_TOO_LONG" => RequestRunningTooLong,
|
368
|
+
"REQUIRED_FIELD_MISSING" => RequiredFieldMissing,
|
369
|
+
"SELF_REFERENCE_FROM_TRIGGER" => SelfReferenceFromTrigger,
|
370
|
+
"SERVER_UNAVAILABLE" => ServerUnavailable,
|
371
|
+
"SHARE_NEEDED_FOR_CHILD_OWNER" => ShareNeededForChildOwner,
|
372
|
+
"SINGLE_EMAIL_LIMIT_EXCEEDED" => SingleEmailLimitExceeded,
|
373
|
+
"STANDARD_PRICE_NOT_DEFINED" => StandardPriceNotDefined,
|
374
|
+
"STORAGE_LIMIT_EXCEEDED" => StorageLimitExceeded,
|
375
|
+
"STRING_TOO_LONG" => StringTooLong,
|
376
|
+
"TABSET_LIMIT_EXCEEDED" => TabsetLimitExceeded,
|
377
|
+
"TEMPLATE_NOT_ACTIVE" => TemplateNotActive,
|
378
|
+
"TERRITORY_REALIGN_IN_PROGRESS" => TerritoryRealignInProgress,
|
379
|
+
"TEXT_DATA_OUTSIDE_SUPPORTED_CHARSET" => TextDataOutsideSupportedCharset,
|
380
|
+
"TOO_MANY_APEX_REQUESTS" => TooManyApexRequests,
|
381
|
+
"TOO_MANY_ENUM_VALUE" => TooManyEnumValue,
|
382
|
+
"TRANSFER_REQUIRES_READ" => TransferRequiresRead,
|
383
|
+
"UNABLE_TO_LOCK_ROW" => UnableToLockRow,
|
384
|
+
"UNAVAILABLE_RECORDTYPE_EXCEPTION" => UnavailableRecordtypeException,
|
385
|
+
"UNDELETE_FAILED" => UndeleteFailed,
|
386
|
+
"UNKNOWN_EXCEPTION" => UnknownException,
|
387
|
+
"UNSPECIFIED_EMAIL_ADDRESS" => UnspecifiedEmailAddress,
|
388
|
+
"UNSUPPORTED_APEX_TRIGGER_OPERATION" => UnsupportedApexTriggerOperation,
|
389
|
+
"UNVERIFIED_SENDER_ADDRESS" => UnverifiedSenderAddress,
|
390
|
+
"WEBLINK_SIZE_LIMIT_EXCEEDED" => WeblinkSizeLimitExceeded,
|
391
|
+
"WEBLINK_URL_INVALID" => WeblinkUrlInvalid,
|
392
|
+
"WRONG_CONTROLLER_TYPE" => WrongControllerType
|
393
|
+
}.freeze
|
394
|
+
|
395
|
+
def self.get_exception_class(error_code)
|
396
|
+
ERROR_EXCEPTION_CLASSES.fetch(error_code) do |_|
|
397
|
+
warn "[restforce] An unrecognised error code, `#{error_code}` has been " \
|
398
|
+
"received from Salesforce. Instead of raising an error-specific exception, " \
|
399
|
+
"we'll raise a generic `ResponseError`. Please report this missing error code" \
|
400
|
+
" on GitHub at <#{GITHUB_ISSUE_URL}>."
|
401
|
+
|
402
|
+
# If we've received an unexpected error where we don't have a specific
|
403
|
+
# class defined, we can return a generic ResponseError instead
|
404
|
+
ResponseError
|
405
|
+
end
|
406
|
+
end
|
407
|
+
|
408
|
+
def self.const_missing(constant_name)
|
409
|
+
warn "[restforce] You're referring to a Restforce error that isn't defined, " \
|
410
|
+
"`#{name}::#{constant_name}` (for example by trying to `rescue` it). This might " \
|
411
|
+
"be our fault - we've recently made some changes to how errors are defined. If " \
|
412
|
+
"you're sure that this is a valid Salesforce error, then please create an " \
|
413
|
+
"issue on GitHub at <#{GITHUB_ISSUE_URL}>."
|
414
|
+
|
415
|
+
super(constant_name)
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'faraday/file_part'
|
5
|
+
rescue LoadError
|
6
|
+
require 'faraday/upload_io'
|
7
|
+
end
|
8
|
+
|
9
|
+
module Restforce
|
10
|
+
if defined?(::Faraday::FilePart)
|
11
|
+
FilePart = Faraday::FilePart
|
12
|
+
|
13
|
+
# Deprecated
|
14
|
+
UploadIO = Faraday::FilePart
|
15
|
+
else
|
16
|
+
# Handle pre-1.0 versions of faraday
|
17
|
+
FilePart = Faraday::UploadIO
|
18
|
+
UploadIO = Faraday::UploadIO
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# This patch is only needed with multipart-post < 2.0.0
|
23
|
+
# 2.0.0 was released in 2013.
|
24
|
+
require 'restforce/patches/parts' unless Parts::Part.method(:new).arity.abs == 4
|