Skip to content

Commit

Permalink
Fix #find_or_create_professor (#10)
Browse files Browse the repository at this point in the history
* Fix Response::Error messages

* Rescue new error in #find_or_create_professor
  • Loading branch information
grmnlrt authored Sep 1, 2023
1 parent 158a8b0 commit 11d8b2d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/edusign/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def find_or_create_professor(first_name:, last_name:, email:)

response.result
rescue Response::Error => e
raise e unless [Response::Error::PROFESSOR_NOT_FOUND_ERROR_MESSAGE, Response::Error::PROFESSOR_DELETED_ERROR_MESSAGE].include?(e.message)
raise e unless [Response::Error::PROFESSOR_NOT_FOUND_ERROR_MESSAGE, Response::Error::PROFESSOR_DELETED_ERROR_MESSAGE].include?(e.message) || e.message.include?(Response::Error::CANNOT_GET_PROFESSOR_BY_EMAIL_ERROR_MESSAGE)

response = create_professor(first_name: first_name, last_name: last_name, email: email)
response.result
Expand Down Expand Up @@ -286,6 +286,7 @@ class Response
class Error < StandardError
PROFESSOR_NOT_FOUND_ERROR_MESSAGE = "professor not found".freeze
PROFESSOR_DELETED_ERROR_MESSAGE = "professor was deleted".freeze
CANNOT_GET_PROFESSOR_BY_EMAIL_ERROR_MESSAGE = "Error - cannot get professor by email".freeze
end

attr_reader :body
Expand Down

0 comments on commit 11d8b2d

Please sign in to comment.