Exception: PostHog::EmailError
- Inherits:
-
StandardError
- Object
- StandardError
- PostHog::EmailError
- Defined in:
- lib/posthog/email_error.rb
Overview
Instance Attribute Summary collapse
-
#code ⇒ String
readonly
PostHog's error code, such as
quota_limited, or an SDK code such asnetwork_error. -
#docs_url ⇒ String?
readonly
A link to the docs for this error.
-
#field ⇒ String?
readonly
The request field the error is about, when PostHog named one.
-
#fix ⇒ String?
readonly
How to fix the request.
-
#name ⇒ String
readonly
A coarse category of the failure, such as
validation_error,rate_limit_exceededorservice_unavailable. -
#retry_after ⇒ Float?
readonly
How long PostHog asked the client to wait before it sends again, in seconds.
-
#status_code ⇒ Integer?
readonly
The HTTP status, when PostHog answered, or file storage's for
attachment_upload_failed. -
#why ⇒ String?
readonly
Why PostHog refused the email.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(code:, message:, status_code: nil, why: nil, fix: nil, docs_url: nil, field: nil, retry_after: nil) ⇒ EmailError
constructor
private
A new instance of EmailError.
Constructor Details
#initialize(code:, message:, status_code: nil, why: nil, fix: nil, docs_url: nil, field: nil, retry_after: nil) ⇒ EmailError
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of EmailError.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/posthog/email_error.rb', line 28 def initialize(code:, message:, status_code: nil, why: nil, fix: nil, docs_url: nil, field: nil, retry_after: nil) super() @name = self.class.name_for(status_code, code) @code = code @status_code = status_code @why = why @fix = fix @docs_url = docs_url @field = field @retry_after = retry_after end |
Instance Attribute Details
#code ⇒ String (readonly)
Returns PostHog's error code, such as quota_limited, or an SDK code such as network_error.
13 14 15 |
# File 'lib/posthog/email_error.rb', line 13 def code @code end |
#docs_url ⇒ String? (readonly)
Returns A link to the docs for this error.
21 22 23 |
# File 'lib/posthog/email_error.rb', line 21 def docs_url @docs_url end |
#field ⇒ String? (readonly)
Returns The request field the error is about, when PostHog named one.
23 24 25 |
# File 'lib/posthog/email_error.rb', line 23 def field @field end |
#fix ⇒ String? (readonly)
Returns How to fix the request.
19 20 21 |
# File 'lib/posthog/email_error.rb', line 19 def fix @fix end |
#name ⇒ String (readonly)
Returns A coarse category of the failure, such as validation_error, rate_limit_exceeded
or service_unavailable.
11 12 13 |
# File 'lib/posthog/email_error.rb', line 11 def name @name end |
#retry_after ⇒ Float? (readonly)
Returns How long PostHog asked the client to wait before it sends again, in seconds.
25 26 27 |
# File 'lib/posthog/email_error.rb', line 25 def retry_after @retry_after end |
#status_code ⇒ Integer? (readonly)
Returns The HTTP status, when PostHog answered, or file storage's for attachment_upload_failed.
15 16 17 |
# File 'lib/posthog/email_error.rb', line 15 def status_code @status_code end |
#why ⇒ String? (readonly)
Returns Why PostHog refused the email.
17 18 19 |
# File 'lib/posthog/email_error.rb', line 17 def why @why end |
Class Method Details
.name_for(status_code, code) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/posthog/email_error.rb', line 49 def self.name_for(status_code, code) return status_code.to_i >= 500 ? 'service_unavailable' : 'application_error' if code == 'attachment_upload_failed' return 'missing_api_key' if code == 'missing_secret_key' || status_code == 401 return SDK_ERROR_NAMES.fetch(code, 'application_error') if status_code.nil? case status_code when 400 then 'validation_error' when 403 then 'invalid_permission' when 404 then 'not_found' when 409 then code == 'template_outdated' ? 'validation_error' : 'concurrent_idempotent_requests' when 422 then code == 'idempotency_key_reused' ? 'invalid_idempotent_request' : 'validation_error' when 429 then code == 'quota_limited' ? 'monthly_quota_exceeded' : 'rate_limit_exceeded' when 503 then 'service_unavailable' else 'application_error' end end |