Exception: FrozenError

Inherits:
RuntimeError show all
Defined in:
error.c,
error.c

Overview

Raised when there is an attempt to modify a frozen object.

[1, 2, 3].freeze << 4

raises the exception:

FrozenError: can't modify frozen Array

Instance Method Summary collapse

Methods inherited from Exception

#==, #backtrace, #backtrace_locations, #cause, #exception, exception, #full_message, #inspect, #message, #set_backtrace, #to_s, to_tty?

Constructor Details

#new(msg = nil, receiver: nil) ⇒ Object

Construct a new FrozenError exception. If given the receiver parameter may subsequently be examined using the FrozenError#receiver method.

a = [].freeze
raise FrozenError.new("can't modify frozen array", receiver: a)


1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
# File 'error.c', line 1501

static VALUE
frozen_err_initialize(int argc, VALUE *argv, VALUE self)
{
    ID keywords[1];
    VALUE values[numberof(keywords)], options;

    argc = rb_scan_args(argc, argv, "*:", NULL, &options);
    keywords[0] = id_receiver;
    rb_get_kwargs(options, keywords, 0, numberof(values), values);
    rb_call_super(argc, argv);
    err_init_recv(self, values[0]);
    return self;
}

Instance Method Details

#receiverObject

Return the receiver associated with this FrozenError exception.

Returns: