Project

General

Profile

Actions

Feature #15883

closed

Include inspect value of object in FrozenError messages

Added by jeremyevans0 (Jeremy Evans) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
[ruby-core:92868]

Description

FrozenError#receiver was added recently for getting the related object programmatically. However, there are cases where FrozenError is raised and not handled, and in those cases the resulting error messages lack detail, which makes debugging the error more difficult, especially in cases where the error is not easily reproducible. This includes the inspect value of the frozen object in FrozenError messages, which should make debugging simpler.

Before:

class A; end
A.freeze
def A.a; end
# can't modify frozen Class
'a'.freeze << 'b'
# can't modify frozen String

After:

class A; end
A.freeze
def A.a; end
# can't modify frozen Class: A
'a'.freeze << 'b'
# can't modify frozen String: "a"

Attached is a patch that implements this feature. If there are no objections, I plan on committing this in about a week.


Files

frozen-error-message-detail.patch (3.23 KB) frozen-error-message-detail.patch jeremyevans0 (Jeremy Evans), 05/28/2019 12:55 AM

Updated by jeremyevans0 (Jeremy Evans) almost 5 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0