Exception: Poodle::ForbiddenError
- Defined in:
- lib/poodle/errors/forbidden_error.rb
Overview
Exception raised when access is forbidden (403 Forbidden)
Instance Attribute Summary collapse
-
#reason ⇒ String?
readonly
Reason for the forbidden access.
Attributes inherited from Error
Class Method Summary collapse
-
.account_suspended(reason, rate = nil) ⇒ ForbiddenError
Create a ForbiddenError for account suspended.
-
.insufficient_permissions ⇒ ForbiddenError
Create a ForbiddenError for insufficient permissions.
Instance Method Summary collapse
-
#initialize(message = "Access forbidden", reason: nil, context: {}) ⇒ ForbiddenError
constructor
Initialize a new ForbiddenError.
Methods inherited from Error
Constructor Details
#initialize(message = "Access forbidden", reason: nil, context: {}) ⇒ ForbiddenError
Initialize a new ForbiddenError
24 25 26 27 |
# File 'lib/poodle/errors/forbidden_error.rb', line 24 def initialize( = "Access forbidden", reason: nil, context: {}) @reason = reason super(, context: context.merge(reason: reason), status_code: 403) end |
Instance Attribute Details
#reason ⇒ String? (readonly)
Returns reason for the forbidden access.
17 18 19 |
# File 'lib/poodle/errors/forbidden_error.rb', line 17 def reason @reason end |
Class Method Details
.account_suspended(reason, rate = nil) ⇒ ForbiddenError
Create a ForbiddenError for account suspended
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/poodle/errors/forbidden_error.rb', line 34 def self.account_suspended(reason, rate = nil) = "Account suspended: #{reason}" += " (Rate: #{rate})" if rate new( , reason: reason, context: { error_type: "account_suspended", suspension_rate: rate } ) end |
.insufficient_permissions ⇒ ForbiddenError
Create a ForbiddenError for insufficient permissions
48 49 50 51 52 53 54 |
# File 'lib/poodle/errors/forbidden_error.rb', line 48 def self. new( "API key does not have sufficient permissions for this operation.", reason: "insufficient_permissions", context: { error_type: "insufficient_permissions" } ) end |