enhanced the ERROR_HANDLER
This commit is contained in:
@@ -8,6 +8,11 @@ note
|
|||||||
class
|
class
|
||||||
ERROR_HANDLER
|
ERROR_HANDLER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
ANY
|
||||||
|
|
||||||
|
DEBUG_OUTPUT
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
@@ -35,6 +40,18 @@ feature -- Status
|
|||||||
errors: LIST [ERROR]
|
errors: LIST [ERROR]
|
||||||
-- Errors container
|
-- Errors container
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
debug_output: STRING
|
||||||
|
-- String that should be displayed in debugger to represent `Current'.
|
||||||
|
do
|
||||||
|
if has_error then
|
||||||
|
Result := count.out + " errors"
|
||||||
|
else
|
||||||
|
Result := "no error"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Basic operation
|
||||||
|
|
||||||
add_error (a_error: ERROR)
|
add_error (a_error: ERROR)
|
||||||
@@ -52,6 +69,12 @@ feature -- Basic operation
|
|||||||
add_error (e)
|
add_error (e)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
append (a_err_handler: ERROR_HANDLER)
|
||||||
|
-- Append errors from `a_err_handler'
|
||||||
|
do
|
||||||
|
errors.append (a_err_handler.errors)
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
as_single_error: detachable ERROR
|
as_single_error: detachable ERROR
|
||||||
@@ -61,6 +84,20 @@ feature -- Access
|
|||||||
elseif count > 0 then
|
elseif count > 0 then
|
||||||
Result := errors.first
|
Result := errors.first
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
has_error_implies_result_attached: has_error implies Result /= Void
|
||||||
|
end
|
||||||
|
|
||||||
|
as_string_representation: STRING
|
||||||
|
require
|
||||||
|
has_error
|
||||||
|
do
|
||||||
|
if attached as_single_error as e then
|
||||||
|
Result := e.string_representation
|
||||||
|
else
|
||||||
|
check has_error: False end
|
||||||
|
Result := "Error occured"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Element changes
|
feature -- Element changes
|
||||||
|
|||||||
Reference in New Issue
Block a user