Project

General

Profile

Feature #15883

Include inspect value of object in FrozenError messages

Added by jeremyevans0 (Jeremy Evans) 9 months ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
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) 9 months ago

  • Status changed from Open to Closed

Also available in: Atom PDF