Exception: PgSqlTriggers::Error
- Inherits:
-
StandardError
- Object
- StandardError
- PgSqlTriggers::Error
- Defined in:
- lib/pg_sql_triggers/errors.rb
Overview
Base error class for all PgSqlTriggers errors
All errors in PgSqlTriggers inherit from this base class and include error codes for programmatic handling, standardized messages, and recovery suggestions.
Direct Known Subclasses
DriftError, ExecutionError, KillSwitchError, NotFoundError, PermissionError, UnsafeMigrationError, ValidationError
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#recovery_suggestion ⇒ Object
readonly
Returns the value of attribute recovery_suggestion.
Instance Method Summary collapse
-
#initialize(message = nil, error_code: nil, recovery_suggestion: nil, context: {}) ⇒ Error
constructor
A new instance of Error.
-
#to_h ⇒ Object
Returns error details as a hash for programmatic access.
-
#user_message ⇒ Object
Returns a user-friendly error message suitable for UI display.
Constructor Details
#initialize(message = nil, error_code: nil, recovery_suggestion: nil, context: {}) ⇒ Error
Returns a new instance of Error.
12 13 14 15 16 17 |
# File 'lib/pg_sql_triggers/errors.rb', line 12 def initialize( = nil, error_code: nil, recovery_suggestion: nil, context: {}) @context = context || {} @error_code = error_code || default_error_code @recovery_suggestion = recovery_suggestion || default_recovery_suggestion super( || ) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
10 11 12 |
# File 'lib/pg_sql_triggers/errors.rb', line 10 def context @context end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
10 11 12 |
# File 'lib/pg_sql_triggers/errors.rb', line 10 def error_code @error_code end |
#recovery_suggestion ⇒ Object (readonly)
Returns the value of attribute recovery_suggestion.
10 11 12 |
# File 'lib/pg_sql_triggers/errors.rb', line 10 def recovery_suggestion @recovery_suggestion end |
Instance Method Details
#to_h ⇒ Object
Returns error details as a hash for programmatic access
27 28 29 30 31 32 33 34 35 |
# File 'lib/pg_sql_triggers/errors.rb', line 27 def to_h { error_class: self.class.name, error_code: error_code, message: , recovery_suggestion: recovery_suggestion, context: context } end |
#user_message ⇒ Object
Returns a user-friendly error message suitable for UI display
20 21 22 23 24 |
# File 'lib/pg_sql_triggers/errors.rb', line 20 def msg = msg += "\n\nRecovery: #{recovery_suggestion}" if recovery_suggestion msg end |