Exception: PgSqlTriggers::DriftError

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

Overview

Error raised when drift is detected

Examples:

raise PgSqlTriggers::DriftError.new(
  "Trigger 'users_email_validation' has drifted from definition",
  error_code: "DRIFT_DETECTED",
  recovery_suggestion: "Run migration to sync trigger, or re-execute trigger to apply current definition",
  context: { trigger_name: "users_email_validation", drift_type: "function_body" }
)

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



122
123
124
# File 'lib/pg_sql_triggers/errors.rb', line 122

def default_error_code
  "DRIFT_DETECTED"
end

#default_messageObject



126
127
128
# File 'lib/pg_sql_triggers/errors.rb', line 126

def default_message
  "Trigger has drifted from its definition"
end

#default_recovery_suggestionObject



130
131
132
133
134
135
# File 'lib/pg_sql_triggers/errors.rb', line 130

def default_recovery_suggestion
  trigger_name = context[:trigger_name] || "trigger"
  "Trigger '#{trigger_name}' has drifted. " \
    "Run 'rake trigger:migrate' to sync the trigger, or use the re-execute feature " \
    "to apply the current definition."
end