Exception: PgSqlTriggers::KillSwitchError

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

Overview

Error raised when kill switch blocks an operation

Examples:

raise PgSqlTriggers::KillSwitchError.new(
  "Kill switch is active for production environment",
  error_code: "KILL_SWITCH_ACTIVE",
  recovery_suggestion: "Provide confirmation text to override: EXECUTE OPERATION_NAME",
  context: { operation: :trigger_enable, environment: "production" }
)

Instance Attribute Summary

Attributes inherited from Error

#context, #error_code, #recovery_suggestion

Instance Method Summary collapse

Methods inherited from Error

#initialize, #to_h, #user_message

Constructor Details

This class inherits a constructor from PgSqlTriggers::Error

Instance Method Details

#default_error_codeObject



94
95
96
# File 'lib/pg_sql_triggers/errors.rb', line 94

def default_error_code
  "KILL_SWITCH_ACTIVE"
end

#default_messageObject



98
99
100
# File 'lib/pg_sql_triggers/errors.rb', line 98

def default_message
  "Kill switch is active for this environment"
end

#default_recovery_suggestionObject



102
103
104
105
106
107
108
109
# File 'lib/pg_sql_triggers/errors.rb', line 102

def default_recovery_suggestion
  ctx = @context || {}
  ctx[:operation] || "this operation"
  environment = ctx[:environment] || "this environment"
  "Kill switch is active for #{environment}. " \
    "To override, provide the required confirmation text. " \
    "For CLI/rake tasks, use: KILL_SWITCH_OVERRIDE=true CONFIRMATION_TEXT=\"...\" rake your:task"
end