Class: RegoValidate::ErrorReporter::JsonFormatter
- Inherits:
-
Object
- Object
- RegoValidate::ErrorReporter::JsonFormatter
- Defined in:
- lib/ruby/rego/cli/reporting.rb
Overview
Emits JSON-formatted error output.
Instance Method Summary collapse
-
#error(message, _parser = nil) ⇒ void
-
#initialize(stdout:, stderr:) ⇒ JsonFormatter
constructor
A new instance of JsonFormatter.
-
#rego_error(error) ⇒ void
Constructor Details
#initialize(stdout:, stderr:) ⇒ JsonFormatter
Returns a new instance of JsonFormatter.
170 171 172 173 |
# File 'lib/ruby/rego/cli/reporting.rb', line 170 def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr end |
Instance Method Details
#error(message, _parser = nil) ⇒ void
This method returns an undefined value.
178 179 180 181 |
# File 'lib/ruby/rego/cli/reporting.rb', line 178 def error(, _parser = nil) payload = ErrorPayload.from_cli_error().to_h stdout.puts(JSON.generate(payload)) end |
#rego_error(error) ⇒ void
This method returns an undefined value.
185 186 187 188 |
# File 'lib/ruby/rego/cli/reporting.rb', line 185 def rego_error(error) payload = ErrorPayload.from_rego_error(error).to_h stdout.puts(JSON.generate(payload)) end |