Change structure of EWF, to follow better categorization
This commit is contained in:
16
library/utility/general/error/error-safe.ecf
Normal file
16
library/utility/general/error/error-safe.ecf
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="error" uuid="C2DFF741-7091-43C7-B8B1-B075E7FF914F" library_target="error">
|
||||
<target name="error">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
16
library/utility/general/error/error.ecf
Normal file
16
library/utility/general/error/error.ecf
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="error" uuid="C2DFF741-7091-43C7-B8B1-B075E7FF914F" library_target="error">
|
||||
<target name="error">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true">
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<cluster name="src" location="src\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
10
library/utility/general/error/license.lic
Normal file
10
library/utility/general/error/license.lic
Normal file
@@ -0,0 +1,10 @@
|
||||
${NOTE_KEYWORD}
|
||||
copyright: "2011-${YEAR}, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
92
library/utility/general/error/src/error.e
Normal file
92
library/utility/general/error/src/error.e
Normal file
@@ -0,0 +1,92 @@
|
||||
note
|
||||
description : "Objects that represent an error"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
ERROR
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
DEBUG_OUTPUT
|
||||
|
||||
feature -- Access
|
||||
|
||||
code: INTEGER
|
||||
deferred
|
||||
ensure
|
||||
result_not_zero: Result /= 0
|
||||
end
|
||||
|
||||
name: READABLE_STRING_8
|
||||
deferred
|
||||
ensure
|
||||
result_attached: Result /= Void
|
||||
end
|
||||
|
||||
message: detachable READABLE_STRING_32
|
||||
-- Potential error message
|
||||
deferred
|
||||
end
|
||||
|
||||
parent: detachable ERROR
|
||||
-- Eventual error prior to Current
|
||||
|
||||
feature -- String representation
|
||||
|
||||
string_representation: STRING_32
|
||||
-- String representation for Current
|
||||
do
|
||||
create Result.make_from_string (name.as_string_32)
|
||||
Result.append_character (' ')
|
||||
Result.append_character ('(')
|
||||
Result.append_integer (code)
|
||||
Result.append_character (')')
|
||||
if attached message as m then
|
||||
Result.append_character (':')
|
||||
Result.append_character (' ')
|
||||
Result.append_string (m)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
debug_output: STRING
|
||||
do
|
||||
Result := string_representation.as_string_8
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_parent (a_parent: like parent)
|
||||
-- Set `parent' to `a_parent'
|
||||
do
|
||||
parent := a_parent
|
||||
end
|
||||
|
||||
feature -- Visitor
|
||||
|
||||
process (a_visitor: ERROR_VISITOR)
|
||||
-- Process Current using `a_visitor'.
|
||||
require
|
||||
a_visitor_not_void: a_visitor /= Void
|
||||
deferred
|
||||
end
|
||||
|
||||
invariant
|
||||
name_attached: name /= Void
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
57
library/utility/general/error/src/error_custom.e
Normal file
57
library/utility/general/error/src/error_custom.e
Normal file
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description : "Objects that represent a custom error"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ERROR_CUSTOM
|
||||
|
||||
inherit
|
||||
ERROR
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_code: INTEGER; a_name: like name; a_message: detachable like message)
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
code := a_code
|
||||
name := a_name
|
||||
if a_message /= Void then
|
||||
message := a_message
|
||||
else
|
||||
message := "Error: " + a_name + " (code=" + a_code.out + ")"
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
code: INTEGER
|
||||
|
||||
name: READABLE_STRING_8
|
||||
|
||||
message: detachable READABLE_STRING_32
|
||||
|
||||
feature -- Visitor
|
||||
|
||||
process (a_visitor: ERROR_VISITOR)
|
||||
-- Process Current using `a_visitor'.
|
||||
do
|
||||
a_visitor.process_custom (Current)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
75
library/utility/general/error/src/error_group.e
Normal file
75
library/utility/general/error/src/error_group.e
Normal file
@@ -0,0 +1,75 @@
|
||||
note
|
||||
description : "Objects that represent a group of errors"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ERROR_GROUP
|
||||
|
||||
inherit
|
||||
ERROR
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_errors: LIST [ERROR])
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
name := a_errors.count.out + " errors"
|
||||
create {ARRAYED_LIST [ERROR]} sub_errors.make (a_errors.count)
|
||||
sub_errors.fill (a_errors)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
code: INTEGER = -1
|
||||
|
||||
name: STRING
|
||||
|
||||
message: detachable STRING_32
|
||||
do
|
||||
create Result.make_from_string (name)
|
||||
from
|
||||
sub_errors.start
|
||||
until
|
||||
sub_errors.after
|
||||
loop
|
||||
if
|
||||
attached sub_errors.item as e and then
|
||||
attached e.message as m
|
||||
then
|
||||
|
||||
Result.append_character ('%N')
|
||||
Result.append_string (m)
|
||||
end
|
||||
sub_errors.forth
|
||||
end
|
||||
end
|
||||
|
||||
sub_errors: LIST [ERROR]
|
||||
-- Error contained by Current
|
||||
|
||||
feature -- Visitor
|
||||
|
||||
process (a_visitor: ERROR_VISITOR)
|
||||
-- Process Current using `a_visitor'.
|
||||
do
|
||||
a_visitor.process_group (Current)
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
314
library/utility/general/error/src/error_handler.e
Normal file
314
library/utility/general/error/src/error_handler.e
Normal file
@@ -0,0 +1,314 @@
|
||||
note
|
||||
description : "Objects that handle error..."
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ERROR_HANDLER
|
||||
|
||||
inherit
|
||||
ANY
|
||||
|
||||
DEBUG_OUTPUT
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize `Current'.
|
||||
do
|
||||
create {ARRAYED_LIST [like errors.item]} errors.make (3)
|
||||
create error_added_actions
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
has_error: BOOLEAN
|
||||
-- Has error?
|
||||
do
|
||||
Result := count > 0
|
||||
end
|
||||
|
||||
count: INTEGER
|
||||
-- Number of error
|
||||
do
|
||||
Result := errors.count
|
||||
end
|
||||
|
||||
feature {ERROR_HANDLER, ERROR_VISITOR} -- Restricted access
|
||||
|
||||
errors: LIST [ERROR]
|
||||
-- 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 -- Events
|
||||
|
||||
error_added_actions: ACTION_SEQUENCE [TUPLE [ERROR]]
|
||||
-- Actions triggered when a new error is added
|
||||
|
||||
feature -- Synchronization
|
||||
|
||||
add_synchronization (h: ERROR_HANDLER)
|
||||
-- Add synchronization between `h' and `Current'
|
||||
--| the same handler can be added more than once
|
||||
--| it will be synchronized only once
|
||||
local
|
||||
lst: like synchronized_handlers
|
||||
do
|
||||
lst := synchronized_handlers
|
||||
if lst = Void then
|
||||
create {ARRAYED_LIST [like synchronized_handlers.item]} lst.make (0)
|
||||
lst.compare_references
|
||||
synchronized_handlers := lst
|
||||
end
|
||||
if lst.has (h) then
|
||||
check attached h.synchronized_handlers as h_lst and then h_lst.has (Current) end
|
||||
else
|
||||
lst.extend (h)
|
||||
h.add_synchronization (Current)
|
||||
end
|
||||
end
|
||||
|
||||
remove_synchronization (h: ERROR_HANDLER)
|
||||
-- Remove synchronization between `h' and `Current'
|
||||
do
|
||||
if attached synchronized_handlers as lst and then not lst.is_empty then
|
||||
synchronized_handlers := Void
|
||||
lst.prune_all (h)
|
||||
|
||||
h.remove_synchronization (Current)
|
||||
|
||||
synchronized_handlers := lst
|
||||
if lst.is_empty then
|
||||
synchronized_handlers := Void
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature {ERROR_HANDLER} -- Synchronization implementation
|
||||
|
||||
synchronized_handlers: detachable LIST [ERROR_HANDLER]
|
||||
-- Synchronized handlers
|
||||
|
||||
synchronize_error_from (e: ERROR; h_lst: LIST [ERROR_HANDLER])
|
||||
-- Called by error_handler during synchronization process
|
||||
-- if `synchronized_handlers' is Void, this means Current is synchronizing
|
||||
-- this is to prevent infinite cycle iteration
|
||||
require
|
||||
not h_lst.has (Current)
|
||||
do
|
||||
h_lst.extend (Current)
|
||||
|
||||
if attached synchronized_handlers as lst then
|
||||
synchronized_handlers := Void
|
||||
add_error (e)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if not h_lst.has (c.item) then
|
||||
c.item.synchronize_error_from (e, h_lst)
|
||||
end
|
||||
end
|
||||
synchronized_handlers := lst
|
||||
else
|
||||
-- In synchronization
|
||||
end
|
||||
end
|
||||
|
||||
synchronize_reset_from (h_lst: LIST [ERROR_HANDLER])
|
||||
-- Called by error_handler during synchronization process
|
||||
-- if `synchronized_handlers' is Void, this means Current is synchronizing
|
||||
-- this is to prevent infinite cycle iteration
|
||||
require
|
||||
not h_lst.has (Current)
|
||||
do
|
||||
h_lst.extend (Current)
|
||||
if attached synchronized_handlers as lst then
|
||||
synchronized_handlers := Void
|
||||
reset
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if not h_lst.has (c.item) then
|
||||
c.item.synchronize_reset_from (h_lst)
|
||||
end
|
||||
end
|
||||
synchronized_handlers := lst
|
||||
else
|
||||
-- In synchronization
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Event: implementation
|
||||
|
||||
on_error_added (e: ERROR)
|
||||
-- Error `e' was just added
|
||||
local
|
||||
sync_list: LINKED_LIST [ERROR_HANDLER]
|
||||
do
|
||||
error_added_actions.call ([e])
|
||||
if attached synchronized_handlers as lst then
|
||||
synchronized_handlers := Void
|
||||
create sync_list.make
|
||||
sync_list.extend (Current)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if not sync_list.has (c.item) then
|
||||
c.item.synchronize_error_from (e, sync_list)
|
||||
end
|
||||
end
|
||||
synchronized_handlers := lst
|
||||
end
|
||||
end
|
||||
|
||||
on_reset
|
||||
-- `reset' was just called
|
||||
local
|
||||
sync_list: LINKED_LIST [ERROR_HANDLER]
|
||||
do
|
||||
if attached synchronized_handlers as lst then
|
||||
synchronized_handlers := Void
|
||||
create sync_list.make
|
||||
sync_list.extend (Current)
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
if not sync_list.has (c.item) then
|
||||
c.item.synchronize_reset_from (sync_list)
|
||||
end
|
||||
end
|
||||
synchronized_handlers := lst
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Basic operation
|
||||
|
||||
add_error (a_error: ERROR)
|
||||
-- Add `a_error' to the stack of error
|
||||
do
|
||||
errors.force (a_error)
|
||||
on_error_added (a_error)
|
||||
end
|
||||
|
||||
add_error_details, add_custom_error (a_code: INTEGER; a_name: STRING; a_message: detachable STRING_32)
|
||||
-- Add custom error to the stack of error
|
||||
local
|
||||
e: ERROR_CUSTOM
|
||||
do
|
||||
create e.make (a_code, a_name, a_message)
|
||||
add_error (e)
|
||||
end
|
||||
|
||||
append (other: ERROR_HANDLER)
|
||||
-- Append errors from `a_err_handler'
|
||||
local
|
||||
other_errs: LIST [ERROR]
|
||||
do
|
||||
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
|
||||
|
||||
feature -- Access
|
||||
|
||||
as_single_error: detachable ERROR
|
||||
-- All error(s) concatenated into one single error.
|
||||
do
|
||||
if count > 1 then
|
||||
create {ERROR_GROUP} Result.make (errors)
|
||||
elseif count > 0 then
|
||||
Result := errors.first
|
||||
end
|
||||
ensure
|
||||
has_error_implies_result_attached: has_error implies Result /= Void
|
||||
end
|
||||
|
||||
as_string_representation: STRING
|
||||
-- String representation of all error(s).
|
||||
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
|
||||
|
||||
feature -- Element changes
|
||||
|
||||
concatenate
|
||||
-- Concatenate into a single error if any
|
||||
do
|
||||
if count > 1 and then attached as_single_error as e then
|
||||
reset
|
||||
add_error (e)
|
||||
end
|
||||
end
|
||||
|
||||
reset
|
||||
-- Reset error handler
|
||||
do
|
||||
if errors.count > 0 then
|
||||
errors.wipe_out
|
||||
on_reset
|
||||
end
|
||||
ensure
|
||||
has_no_error: not has_error
|
||||
count = 0
|
||||
end
|
||||
|
||||
destroy
|
||||
-- Destroy Current, and remove any synchronization
|
||||
do
|
||||
error_added_actions.wipe_out
|
||||
if attached synchronized_handlers as lst then
|
||||
across
|
||||
lst as c
|
||||
loop
|
||||
c.item.remove_synchronization (Current)
|
||||
end
|
||||
end
|
||||
synchronized_handlers := Void
|
||||
reset
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
11
library/utility/general/error/src/error_handler_with_event.e
Normal file
11
library/utility/general/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$"
|
||||
|
||||
|
||||
49
library/utility/general/error/src/visitor/error_iterator.e
Normal file
49
library/utility/general/error/src/visitor/error_iterator.e
Normal file
@@ -0,0 +1,49 @@
|
||||
note
|
||||
description : "Error list iterator"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ERROR_ITERATOR
|
||||
|
||||
inherit
|
||||
ERROR_VISITOR
|
||||
|
||||
feature -- Access
|
||||
|
||||
process_error (e: ERROR)
|
||||
do
|
||||
end
|
||||
|
||||
process_custom (e: ERROR_CUSTOM)
|
||||
do
|
||||
process_error (e)
|
||||
end
|
||||
|
||||
process_group (g: ERROR_GROUP)
|
||||
do
|
||||
if attached g.sub_errors as err then
|
||||
from
|
||||
err.start
|
||||
until
|
||||
err.after
|
||||
loop
|
||||
process_error (err.item)
|
||||
err.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,38 @@
|
||||
note
|
||||
description : "Null error visitor"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ERROR_NULL_VISITOR
|
||||
|
||||
inherit
|
||||
ERROR_VISITOR
|
||||
|
||||
feature -- Access
|
||||
|
||||
process_error (e: ERROR)
|
||||
do
|
||||
end
|
||||
|
||||
process_custom (e: ERROR_CUSTOM)
|
||||
do
|
||||
end
|
||||
|
||||
process_group (g: ERROR_GROUP)
|
||||
do
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
35
library/utility/general/error/src/visitor/error_visitor.e
Normal file
35
library/utility/general/error/src/visitor/error_visitor.e
Normal file
@@ -0,0 +1,35 @@
|
||||
note
|
||||
description : "Objects to visit an ERROR"
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
ERROR_VISITOR
|
||||
|
||||
feature -- Access
|
||||
|
||||
process_error (e: ERROR)
|
||||
deferred
|
||||
end
|
||||
|
||||
process_custom (e: ERROR_CUSTOM)
|
||||
deferred
|
||||
end
|
||||
|
||||
process_group (g: ERROR_GROUP)
|
||||
deferred
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description: "File error output visitor"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
FILE_OUTPUT_ERROR_VISITOR
|
||||
|
||||
inherit
|
||||
OUTPUT_ERROR_VISITOR
|
||||
redefine
|
||||
output_integer,
|
||||
output_new_line
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (f: like file)
|
||||
require
|
||||
f_open_write: f /= Void and then f.is_open_write
|
||||
do
|
||||
file := f
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
file: FILE
|
||||
|
||||
feature -- Output
|
||||
|
||||
output_string (a_str: detachable READABLE_STRING_GENERAL)
|
||||
-- Output Unicode string
|
||||
do
|
||||
if a_str /= Void then
|
||||
to_implement ("Convert into UTF-8 or console encoding before output")
|
||||
file.put_string (a_str.as_string_8)
|
||||
end
|
||||
end
|
||||
|
||||
output_integer (i: INTEGER)
|
||||
do
|
||||
file.put_integer (i)
|
||||
end
|
||||
|
||||
output_new_line
|
||||
do
|
||||
file.put_new_line
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,93 @@
|
||||
note
|
||||
description: "General error output visitor"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
OUTPUT_ERROR_VISITOR
|
||||
|
||||
inherit
|
||||
ERROR_VISITOR
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
feature -- Output
|
||||
|
||||
output_string (a_str: detachable READABLE_STRING_GENERAL)
|
||||
-- Output Unicode string
|
||||
deferred
|
||||
end
|
||||
|
||||
output_any (obj: detachable ANY)
|
||||
-- Output Unicode string
|
||||
do
|
||||
if attached {READABLE_STRING_GENERAL} obj as l_str then
|
||||
to_implement ("Convert into UTF-8 or console encoding before output")
|
||||
output_string (l_str)
|
||||
elseif obj /= Void then
|
||||
output_string (obj.out)
|
||||
end
|
||||
end
|
||||
|
||||
output_integer (i: INTEGER)
|
||||
do
|
||||
output_string (i.out)
|
||||
end
|
||||
|
||||
output_new_line
|
||||
do
|
||||
output_string ("%N")
|
||||
end
|
||||
|
||||
feature -- Process
|
||||
|
||||
process_error (e: ERROR)
|
||||
do
|
||||
output_string ({STRING_32}"Error Name: ")
|
||||
output_string (e.name)
|
||||
output_string ({STRING_32}"Code: ")
|
||||
output_integer (e.code)
|
||||
output_new_line
|
||||
output_string ({STRING_32}"%TMessage: ")
|
||||
output_string (e.message)
|
||||
output_new_line
|
||||
end
|
||||
|
||||
process_custom (e: ERROR_CUSTOM)
|
||||
do
|
||||
output_string ({STRING_32}"Error Name: ")
|
||||
output_string (e.name)
|
||||
output_string ({STRING_32}"Code: ")
|
||||
output_integer (e.code)
|
||||
output_new_line
|
||||
output_string ({STRING_32}"%TMessage: ")
|
||||
output_string (e.message)
|
||||
output_new_line
|
||||
end
|
||||
|
||||
process_group (g: ERROR_GROUP)
|
||||
local
|
||||
l_errors: LIST [ERROR]
|
||||
do
|
||||
from
|
||||
l_errors := g.sub_errors
|
||||
l_errors.start
|
||||
until
|
||||
l_errors.after
|
||||
loop
|
||||
l_errors.item.process (Current)
|
||||
l_errors.forth
|
||||
end
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -0,0 +1,63 @@
|
||||
note
|
||||
description: "Text error output visitor"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
TEXT_OUTPUT_ERROR_VISITOR
|
||||
|
||||
inherit
|
||||
OUTPUT_ERROR_VISITOR
|
||||
redefine
|
||||
output_integer,
|
||||
output_new_line
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
make (buf: like buffer)
|
||||
require
|
||||
buf_attached: buf /= Void
|
||||
do
|
||||
buffer := buf
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
buffer: STRING
|
||||
|
||||
feature -- Output
|
||||
|
||||
output_string (a_str: detachable READABLE_STRING_GENERAL)
|
||||
-- Output Unicode string
|
||||
do
|
||||
if a_str /= Void then
|
||||
to_implement ("Convert into UTF-8 or console encoding before output")
|
||||
buffer.append_string_general (a_str)
|
||||
end
|
||||
end
|
||||
|
||||
output_integer (i: INTEGER)
|
||||
do
|
||||
buffer.append_integer (i)
|
||||
end
|
||||
|
||||
output_new_line
|
||||
do
|
||||
buffer.append_character ('%N')
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
182
library/utility/general/error/tests/test_error.e
Normal file
182
library/utility/general/error/tests/test_error.e
Normal file
@@ -0,0 +1,182 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
TEST_ERROR
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
feature -- Test routines
|
||||
|
||||
test_error
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h: ERROR_HANDLER
|
||||
cl: CELL [INTEGER]
|
||||
do
|
||||
create h.make
|
||||
h.add_custom_error (123, "abc", "abc error occurred")
|
||||
h.add_custom_error (456, "abc", "abc error occurred")
|
||||
assert ("has 2 errors", h.count = 2)
|
||||
h.reset
|
||||
assert ("reset then no error", h.count = 0)
|
||||
|
||||
-- error_added_actions
|
||||
create cl.put (0)
|
||||
h.error_added_actions.extend (agent (i_e: ERROR; i_cl: CELL [INTEGER]) do i_cl.replace (i_cl.item + 1) end(?, cl))
|
||||
h.add_custom_error (123, "abc", "abc error occurred")
|
||||
h.add_custom_error (456, "abc", "abc error occurred")
|
||||
assert ("has 2 errors, same as counted", h.count = 2 and h.count = cl.item)
|
||||
|
||||
end
|
||||
|
||||
test_sync_2
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h1, h2: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make
|
||||
create h2.make
|
||||
h1.add_synchronization (h2)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "abc", "abc error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count)
|
||||
|
||||
h1.reset
|
||||
assert ("reset then no error", h1.count = 0 and h2.count = h1.count)
|
||||
|
||||
end
|
||||
|
||||
test_sync_3
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h1, h2, h3: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make
|
||||
create h2.make
|
||||
create h3.make
|
||||
|
||||
h1.add_synchronization (h2)
|
||||
h2.add_synchronization (h3)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "abc", "abc error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count)
|
||||
|
||||
h1.reset
|
||||
assert ("reset then no error", h1.count = 0 and h2.count = h1.count and h3.count = h2.count)
|
||||
|
||||
end
|
||||
|
||||
test_sync_3_with_cycle
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h1, h2, h3: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make
|
||||
create h2.make
|
||||
create h3.make
|
||||
|
||||
h1.add_synchronization (h2)
|
||||
h2.add_synchronization (h3)
|
||||
h3.add_synchronization (h1)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "abc", "abc error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count)
|
||||
|
||||
h1.reset
|
||||
assert ("reset then no error", h1.count = 0 and h2.count = h1.count and h3.count = h2.count)
|
||||
|
||||
end
|
||||
|
||||
test_remove_sync
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h1, h2, h3: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make
|
||||
create h2.make
|
||||
create h3.make
|
||||
|
||||
h1.add_synchronization (h2)
|
||||
h2.add_synchronization (h3)
|
||||
h3.add_synchronization (h1)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "def", "def error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count)
|
||||
|
||||
h2.remove_synchronization (h3)
|
||||
h2.remove_synchronization (h1)
|
||||
|
||||
h1.add_custom_error (789, "ghi", "ghi error occurred")
|
||||
assert ("correct count of errors", h1.count = 3 and h2.count = 2 and h3.count = h1.count)
|
||||
|
||||
h1.reset
|
||||
assert ("reset then no error", h1.count = 0 and h2.count = 2 and h3.count = h1.count)
|
||||
end
|
||||
|
||||
test_destroy
|
||||
note
|
||||
testing: "error"
|
||||
local
|
||||
h1, h2, h3: ERROR_HANDLER
|
||||
-- cl: CELL [INTEGER]
|
||||
do
|
||||
create h1.make
|
||||
create h2.make
|
||||
create h3.make
|
||||
|
||||
h1.add_synchronization (h2)
|
||||
h2.add_synchronization (h3)
|
||||
h3.add_synchronization (h1)
|
||||
|
||||
h1.add_custom_error (123, "abc", "abc error occurred")
|
||||
h1.add_custom_error (456, "def", "def error occurred")
|
||||
|
||||
assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count)
|
||||
|
||||
h2.destroy
|
||||
|
||||
h1.add_custom_error (789, "ghi", "ghi error occurred")
|
||||
assert ("correct count of errors", h1.count = 3 and h2.count = 0 and h3.count = h1.count)
|
||||
|
||||
h1.reset
|
||||
assert ("reset then no error", h1.count = 0 and h2.count = h1.count and h3.count = h1.count)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "Copyright (c) 1984-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
|
||||
18
library/utility/general/error/tests/tests-safe.ecf
Normal file
18
library/utility/general/error/tests/tests-safe.ecf
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="error_tests" uuid="54F59BB2-AD49-42C7-ABAA-B60765F4F926">
|
||||
<target name="error_tests">
|
||||
<root class="ANY" feature="default_create"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<assertions precondition="true"/>
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="error" location="..\error-safe.ecf" readonly="false"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
|
||||
<tests name="tests" location=".\"/>
|
||||
</target>
|
||||
</system>
|
||||
Reference in New Issue
Block a user