Module: LanguageOperator::Errors
- Defined in:
- lib/language_operator/errors.rb
Overview
Standardized error formatting module for consistent error messages across tools
Class Method Summary collapse
-
.access_denied(context = 'check RBAC permissions') ⇒ String
Access denied error.
-
.empty_field(field_name) ⇒ String
Empty/missing required field error.
-
.file_not_found(file_path, context = 'file') ⇒ String
File not found error.
-
.file_permission_denied(file_path, context = 'file') ⇒ String
File permission error.
-
.file_syntax_error(file_path, original_error, context = 'file') ⇒ String
File syntax error.
-
.invalid_json(param_name) ⇒ String
Invalid JSON parameter error.
-
.invalid_parameter(param_name, value, expected) ⇒ String
Invalid parameter value error.
-
.missing_config(missing_vars) ⇒ String
Missing configuration error.
-
.not_found(resource_type, identifier) ⇒ String
Resource not found error.
-
.operation_failed(operation, reason) ⇒ String
Generic operation failed error.
-
.path_traversal_blocked(context = 'file operation') ⇒ String
Path traversal security error.
Class Method Details
.access_denied(context = 'check RBAC permissions') ⇒ String
Access denied error
30 31 32 |
# File 'lib/language_operator/errors.rb', line 30 def self.access_denied(context = 'check RBAC permissions') "Error: Access denied - #{context}" end |
.empty_field(field_name) ⇒ String
Empty/missing required field error
69 70 71 |
# File 'lib/language_operator/errors.rb', line 69 def self.empty_field(field_name) "Error: #{field_name} cannot be empty" end |
.file_not_found(file_path, context = 'file') ⇒ String
File not found error
77 78 79 80 |
# File 'lib/language_operator/errors.rb', line 77 def self.file_not_found(file_path, context = 'file') "Error: #{context.capitalize} not found at '#{file_path}'. " \ 'Please check the file path exists and is accessible.' end |
.file_permission_denied(file_path, context = 'file') ⇒ String
File permission error
86 87 88 89 |
# File 'lib/language_operator/errors.rb', line 86 def self.(file_path, context = 'file') "Error: Permission denied reading #{context} '#{file_path}'. " \ 'Please check file permissions or run with appropriate access rights.' end |
.file_syntax_error(file_path, original_error, context = 'file') ⇒ String
File syntax error
96 97 98 99 |
# File 'lib/language_operator/errors.rb', line 96 def self.file_syntax_error(file_path, original_error, context = 'file') "Error: Syntax error in #{context} '#{file_path}': #{original_error}. " \ 'Please check the file for valid Ruby syntax.' end |
.invalid_json(param_name) ⇒ String
Invalid JSON parameter error
37 38 39 |
# File 'lib/language_operator/errors.rb', line 37 def self.invalid_json(param_name) "Error: Invalid JSON in #{param_name} parameter" end |
.invalid_parameter(param_name, value, expected) ⇒ String
Invalid parameter value error
54 55 56 |
# File 'lib/language_operator/errors.rb', line 54 def self.invalid_parameter(param_name, value, expected) "Error: Invalid #{param_name} '#{value}'. Expected: #{expected}" end |
.missing_config(missing_vars) ⇒ String
Missing configuration error
44 45 46 47 |
# File 'lib/language_operator/errors.rb', line 44 def self.missing_config(missing_vars) vars = Array(missing_vars).join(', ') "Error: Missing configuration: #{vars}" end |
.not_found(resource_type, identifier) ⇒ String
Resource not found error
23 24 25 |
# File 'lib/language_operator/errors.rb', line 23 def self.not_found(resource_type, identifier) "Error: #{resource_type} not found - #{identifier}" end |
.operation_failed(operation, reason) ⇒ String
Generic operation failed error
62 63 64 |
# File 'lib/language_operator/errors.rb', line 62 def self.operation_failed(operation, reason) "Error: #{operation} failed - #{reason}" end |
.path_traversal_blocked(context = 'file operation') ⇒ String
Path traversal security error
104 105 106 107 108 |
# File 'lib/language_operator/errors.rb', line 104 def self.path_traversal_blocked(context = 'file operation') "Error: Path traversal attempt blocked during #{context}. " \ 'File path must be within allowed directories. ' \ 'Use relative paths or configure LANGOP_ALLOWED_PATHS if needed.' end |