Exception: MailCapture::AuthError

Inherits:
Error
  • Object
show all
Defined in:
lib/mailcapture/errors.rb

Overview

Raised when authentication fails — the API key is invalid, expired, or revoked.

rescue MailCapture::AuthError
  # Check your MAILCAPTURE_API_KEY environment variable.
end

Instance Attribute Summary

Attributes inherited from Error

#code

Instance Method Summary collapse

Constructor Details

#initialize(detail = nil) ⇒ AuthError

Returns a new instance of AuthError.



19
20
21
22
23
24
25
26
27
28
# File 'lib/mailcapture/errors.rb', line 19

def initialize(detail = nil)
  hint = detail ? "Server said: #{detail.inspect}." : 'Your API key was rejected.'
  super(
    "Authentication failed. #{hint} " \
    'Make sure your key is valid and has not been revoked. ' \
    'Keys look like: mc_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. ' \
    'Find your keys at https://mailcapture.app/admin/api-keys',
    code: 'UNAUTHORIZED'
  )
end