minor enhancement of error lib
This commit is contained in:
@@ -22,6 +22,7 @@ feature {NONE} -- Initialization
|
|||||||
-- Initialize `Current'.
|
-- Initialize `Current'.
|
||||||
do
|
do
|
||||||
create {ARRAYED_LIST [ERROR]} errors.make (3)
|
create {ARRAYED_LIST [ERROR]} errors.make (3)
|
||||||
|
create error_added_actions
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Status
|
feature -- Status
|
||||||
@@ -37,6 +38,8 @@ feature -- Status
|
|||||||
Result := errors.count
|
Result := errors.count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature {ERROR_HANDLER, ERROR_VISITOR} -- Restricted access
|
||||||
|
|
||||||
errors: LIST [ERROR]
|
errors: LIST [ERROR]
|
||||||
-- Errors container
|
-- Errors container
|
||||||
|
|
||||||
@@ -52,12 +55,26 @@ feature -- Status report
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Events
|
||||||
|
|
||||||
|
error_added_actions: ACTION_SEQUENCE [TUPLE [ERROR]]
|
||||||
|
-- Actions triggered when a new error is added
|
||||||
|
|
||||||
|
feature {NONE} -- Event: implementation
|
||||||
|
|
||||||
|
on_error_added (e: ERROR)
|
||||||
|
-- Error `e' was just added
|
||||||
|
do
|
||||||
|
error_added_actions.call ([e])
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Basic operation
|
||||||
|
|
||||||
add_error (a_error: ERROR)
|
add_error (a_error: ERROR)
|
||||||
-- Add `a_error' to the stack of error
|
-- Add `a_error' to the stack of error
|
||||||
do
|
do
|
||||||
errors.force (a_error)
|
errors.force (a_error)
|
||||||
|
on_error_added (a_error)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_error_details, add_custom_error (a_code: INTEGER; a_name: STRING; a_message: detachable STRING_32)
|
add_error_details, add_custom_error (a_code: INTEGER; a_name: STRING; a_message: detachable STRING_32)
|
||||||
@@ -69,10 +86,25 @@ feature -- Basic operation
|
|||||||
add_error (e)
|
add_error (e)
|
||||||
end
|
end
|
||||||
|
|
||||||
append (a_err_handler: ERROR_HANDLER)
|
append (other: ERROR_HANDLER)
|
||||||
-- Append errors from `a_err_handler'
|
-- Append errors from `a_err_handler'
|
||||||
|
local
|
||||||
|
other_errs: LIST [ERROR]
|
||||||
do
|
do
|
||||||
errors.append (a_err_handler.errors)
|
other_errs := other.errors
|
||||||
|
if other_errs.count > 0 then
|
||||||
|
from
|
||||||
|
other_errs.start
|
||||||
|
until
|
||||||
|
other_errs.after
|
||||||
|
loop
|
||||||
|
add_error (other_errs.item)
|
||||||
|
other_errs.forth
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ensure
|
||||||
|
other_error_appended: other.has_error implies has_error
|
||||||
|
new_count: count = old count + other.count
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
@@ -107,7 +139,7 @@ feature -- Element changes
|
|||||||
do
|
do
|
||||||
if count > 1 and then attached as_single_error as e then
|
if count > 1 and then attached as_single_error as e then
|
||||||
wipe_out
|
wipe_out
|
||||||
add_error (e)
|
errors.force (e)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
11
library/error/src/error_handler_with_event.e
Normal file
11
library/error/src/error_handler_with_event.e
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
note
|
||||||
|
|
||||||
|
description: "Summary description for {ERROR_HANDLER_WITH_EVENT}."
|
||||||
|
|
||||||
|
author: ""
|
||||||
|
|
||||||
|
date: "$Date$"
|
||||||
|
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user