class Canon::ValidationError
the error location and nature.
or fails validation checks. It includes detailed information about
This error is raised when input (XML, HTML, JSON, YAML) is malformed
Error raised when input validation fails
def build_message(msg)
-
(String)- The formatted error message
Parameters:
-
msg(String) -- The base error message
def build_message(msg) parts = ["#{format.to_s.upcase} Validation Error: #{msg}"] parts << " Line: #{line}" if line parts << " Column: #{column}" if column parts << " Details: #{details}" if details parts.join("\n") end
def initialize(message, format:, line: nil, column: nil, details: nil)
-
details(String, nil) -- Additional details about the error -
column(Integer, nil) -- The column number where the error occurred -
line(Integer, nil) -- The line number where the error occurred -
format(Symbol) -- The format being validated (:xml, :html, :json, -
message(String) -- The error message
def initialize(message, format:, line: nil, column: nil, details: nil) @format = format @line = line @column = column @details = details super(build_message(message)) end