class JSON::GeneratorError - Documentation for Ruby 4.0
Description: class JSON::GeneratorError: This exception is raised if a generator or unparser error occurs.
Keywords: ruby,class,JSON::GeneratorError

🔍

No recent searches

# class JSON::GeneratorError

This exception is raised if a generator or unparser error occurs.

### Attributes

invalid_object [R]

### Public Class Methods

new (message, invalid_object = nil)
Source

    # File ext/json/lib/json/common.rb, line 260
    def initialize(message, invalid_object = nil)
      super(message)
      @invalid_object = invalid_object
    end

Calls superclass method `Exception::new`

### Public Instance Methods

detailed_message (...)
Source

    # File ext/json/lib/json/common.rb, line 265
    def detailed_message(...)
      # Exception#detailed_message doesn't exist until Ruby 3.2
      super_message = defined?(super) ? super : message

      if @invalid_object.nil?
        super_message
      else
        "#{super_message}\nInvalid object: #{@invalid_object.inspect}"
      end
    end

Calls superclass method `Exception#detailed_message`