Skip to content

Commit ee70f76

Browse files
author
sofia
committed
ResourceNotUnique error when trying to create a resource that already exists in Intercom. (Intercom HTTP error code: resource_conflict)
1 parent a5f1602 commit ee70f76

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/intercom/errors.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class ServiceConnectionError < IntercomError; end
4242
# Raised when requesting resources on behalf of a user that doesn't exist in your application on Intercom.
4343
class ResourceNotFound < IntercomError; end
4444

45+
# Raised when trying to create a resource that already exists in Intercom.
46+
class ResourceNotUniqueError < IntercomError; end
47+
4548
# Raised when the request has bad syntax
4649
class BadRequestError < IntercomError; end
4750

@@ -55,13 +58,13 @@ class UnexpectedError < IntercomError; end
5558
class MultipleMatchingUsersError < IntercomError; end
5659

5760
# Raised when restoring a blocked user
58-
class BlockedUserError < IntercomError ; end
61+
class BlockedUserError < IntercomError; end
5962

6063
# Raised when you try to call a non-setter method that does not exist on an object
61-
class Intercom::AttributeNotSetError < IntercomError ; end
64+
class Intercom::AttributeNotSetError < IntercomError; end
6265

6366
# Raised when unexpected nil returned from server
64-
class Intercom::HttpError < IntercomError ; end
67+
class Intercom::HttpError < IntercomError; end
6568

6669
#
6770
# Non-public errors (internal to the gem)

lib/intercom/request.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ def raise_application_errors_on_failure(error_list_details, http_code)
163163
raise Intercom::ServiceUnavailableError.new(error_details['message'], error_context)
164164
when 'conflict', 'unique_user_constraint'
165165
raise Intercom::MultipleMatchingUsersError.new(error_details['message'], error_context)
166+
when 'resource_conflict'
167+
raise Intercom::ResourceNotUniqueError.new(error_details['message'], error_context)
166168
when nil, ''
167169
raise Intercom::UnexpectedError.new(message_for_unexpected_error_without_type(error_details, parsed_http_code), error_context)
168170
else

0 commit comments

Comments
 (0)