@@ -23,7 +23,7 @@ class Error
2323 map [ const_get ( code ) ] = code
2424 end
2525 end
26-
26+
2727 # Verbose error handler
2828 VERBOSE_HANDLER = lambda do |error |
2929 STDERR << error . to_s << "\n "
@@ -33,11 +33,20 @@ class Error
3333 # Quiet error handler
3434 QUIET_HANDLER = lambda do |error |
3535 end
36-
36+
37+ # call-seq:
38+ # error == other -> true or false
39+ #
40+ # Returns whether two errors have the same attributes.
3741 def ==( other )
3842 eql? ( other )
3943 end
40-
44+
45+ # call-seq:
46+ # error.eql?(other) -> true or false
47+ #
48+ # Returns whether two errors have identical code, domain, message,
49+ # level, file, line, and all other attributes.
4150 def eql? ( other )
4251 self . code == other . code and
4352 self . domain == other . domain and
@@ -56,6 +65,11 @@ def eql?(other)
5665 false
5766 end
5867
68+ # call-seq:
69+ # error.level_to_s -> String
70+ #
71+ # Returns a human-readable string for the error level:
72+ # "Warning:", "Error:", "Fatal error:", or "".
5973 def level_to_s
6074 case self . level
6175 when NONE
@@ -69,14 +83,27 @@ def level_to_s
6983 end
7084 end
7185
86+ # call-seq:
87+ # error.domain_to_s -> String
88+ #
89+ # Returns the name of the error domain (e.g. "PARSER", "XPATH").
7290 def domain_to_s
7391 DOMAIN_CODE_MAP [ self . domain ] . to_s
7492 end
7593
94+ # call-seq:
95+ # error.code_to_s -> String
96+ #
97+ # Returns the name of the error code constant.
7698 def code_to_s
7799 ERROR_CODE_MAP [ self . code ] . to_s
78100 end
79101
102+ # call-seq:
103+ # error.to_s -> String
104+ #
105+ # Returns a formatted error string including the level, message,
106+ # and file/line when available.
80107 def to_s
81108 msg = super
82109 msg = msg ? msg . strip : ''
0 commit comments