From 7feb45b54980d8b8ec28ea74d75169747572dc14 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 20 Jun 2017 18:08:50 +0200 Subject: [PATCH] Updated error library (cosmetic, and loop iteration). --- library/utility/general/error/src/error.e | 10 ++-- .../utility/general/error/src/error_group.e | 17 +++--- .../utility/general/error/src/error_handler.e | 53 ++++++++----------- .../error/src/visitor/error_iterator.e | 11 ++-- .../src/visitor/file_output_error_visitor.e | 6 +-- .../error/src/visitor/output_error_visitor.e | 19 ++++--- .../src/visitor/text_output_error_visitor.e | 6 +-- 7 files changed, 51 insertions(+), 71 deletions(-) diff --git a/library/utility/general/error/src/error.e b/library/utility/general/error/src/error.e index f5231c09..62f8c272 100644 --- a/library/utility/general/error/src/error.e +++ b/library/utility/general/error/src/error.e @@ -28,17 +28,17 @@ feature -- Access end message: detachable READABLE_STRING_32 - -- Potential error message + -- Potential error message. deferred end parent: detachable ERROR - -- Eventual error prior to Current + -- Eventual error prior to Current. feature -- String representation string_representation: STRING_32 - -- String representation for Current + -- String representation for Current. do create Result.make_from_string (name.as_string_32) Result.append_character (' ') @@ -62,7 +62,7 @@ feature -- Status report feature -- Change set_parent (a_parent: like parent) - -- Set `parent' to `a_parent' + -- Set `parent' to `a_parent'. do parent := a_parent end @@ -80,7 +80,7 @@ invariant name_attached: name /= Void note - copyright: "2011-2014, Jocelyn Fiat, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/utility/general/error/src/error_group.e b/library/utility/general/error/src/error_group.e index df101759..749d8d66 100644 --- a/library/utility/general/error/src/error_group.e +++ b/library/utility/general/error/src/error_group.e @@ -30,28 +30,24 @@ feature -- Access name: STRING - message: detachable STRING_32 + message: STRING_32 do create Result.make_from_string (name) - from - sub_errors.start - until - sub_errors.after + across + sub_errors as s loop if - attached sub_errors.item as e and then + attached s.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 + -- Error contained by Current. feature -- Visitor @@ -61,9 +57,8 @@ feature -- Visitor a_visitor.process_group (Current) end - note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/utility/general/error/src/error_handler.e b/library/utility/general/error/src/error_handler.e index 9cd9e1de..d0a636be 100644 --- a/library/utility/general/error/src/error_handler.e +++ b/library/utility/general/error/src/error_handler.e @@ -1,19 +1,14 @@ note - description : "[ - Error handler or receiver. - - ]" + description : "Error handler or receiver." legal: "See notice at end of class." status: "See notice at end of class." - date: "$Date: 2015-10-10 00:55:41 +0200 (sam., 10 oct. 2015) $" - revision: "$Revision: 97980 $" + date: "$Date$" + revision: "$Revision$" class ERROR_HANDLER inherit - ANY - DEBUG_OUTPUT create @@ -46,7 +41,7 @@ feature -- Access -- Optional identifier for Current handler. primary_error_code: INTEGER - -- Code of first error in `errors' + -- Code of first error in `errors'. require at_least_one_error: has_error do @@ -62,7 +57,7 @@ feature -- Status end count: INTEGER - -- Number of error + -- Number of error. do Result := errors.count end @@ -83,7 +78,7 @@ feature -- Status feature {ERROR_HANDLER, ERROR_VISITOR} -- Restricted access errors: LIST [ERROR] - -- Errors container + -- Errors container. feature -- Status report @@ -119,12 +114,12 @@ feature -- Status report feature -- Events error_added_actions: ACTION_SEQUENCE [TUPLE [ERROR]] - -- Actions triggered when a new error is added + -- Actions triggered when a new error is added. feature -- Synchronization add_synchronization (h: ERROR_HANDLER) - -- Add synchronization between `h' and `Current' + -- Add synchronization between `h' and `Current`. --| the same handler can be added more than once --| it will be synchronized only once do @@ -133,7 +128,7 @@ feature -- Synchronization end remove_synchronization (h: ERROR_HANDLER) - -- Remove synchronization between `h' and `Current' + -- Remove synchronization between `h' and `Current'. do remove_propagation (h) h.remove_propagation (Current) @@ -347,7 +342,7 @@ feature {NONE} -- Event: implementation end on_reset - -- `reset' was just called + -- `reset' was just called. local sync_list: detachable ARRAYED_LIST [ERROR_HANDLER] lst: detachable LIST [ERROR_HANDLER] @@ -389,7 +384,7 @@ feature {NONE} -- Event: implementation feature -- Basic operation add_error (a_error: ERROR) - -- Add `a_error' to the stack of error + -- Add `a_error' to the stack of error. do errors.force (a_error) on_error_added (a_error) @@ -406,28 +401,22 @@ feature -- Basic operation end add_error_details, add_custom_error (a_code: INTEGER; a_name: STRING; a_message: detachable READABLE_STRING_GENERAL) - -- Add custom error to the stack of error - local - e: ERROR_CUSTOM + -- Add custom error to the stack of error. do - create e.make (a_code, a_name, a_message) - add_error (e) + add_error (create {ERROR_CUSTOM}.make (a_code, a_name, a_message)) end append (other: ERROR_HANDLER) - -- Append errors from `a_err_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 + if other_errs /= errors and then other_errs.count > 0 then + across + other_errs as e loop - add_error (other_errs.item) - other_errs.forth + add_error (e.item) end end ensure @@ -435,7 +424,7 @@ feature -- Basic operation new_count: count = old count + other.count end -feature -- Access +feature -- Conversion as_single_error: detachable ERROR -- All error(s) concatenated into one single error. @@ -465,7 +454,7 @@ feature -- Access feature -- Element changes concatenate - -- Concatenate into a single error if any + -- Concatenate into a single error if any. do if count > 1 and then attached as_single_error as e then reset @@ -516,7 +505,7 @@ invariant propagators_not_empty: attached propagators as lst implies not lst.is_empty note - copyright: "2011-2016, Jocelyn Fiat, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/utility/general/error/src/visitor/error_iterator.e b/library/utility/general/error/src/visitor/error_iterator.e index 0102544a..10005a5e 100644 --- a/library/utility/general/error/src/visitor/error_iterator.e +++ b/library/utility/general/error/src/visitor/error_iterator.e @@ -25,19 +25,16 @@ feature -- Access process_group (g: ERROR_GROUP) do if attached g.sub_errors as err then - from - err.start - until - err.after + across + err as e loop - process_error (err.item) - err.forth + process_error (e.item) end end end note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/utility/general/error/src/visitor/file_output_error_visitor.e b/library/utility/general/error/src/visitor/file_output_error_visitor.e index 49e9493f..e4276d18 100644 --- a/library/utility/general/error/src/visitor/file_output_error_visitor.e +++ b/library/utility/general/error/src/visitor/file_output_error_visitor.e @@ -16,7 +16,7 @@ inherit create make -feature -- Initialization +feature {NONE} -- Creation make (f: like file) require @@ -32,7 +32,7 @@ feature -- Access feature -- Output output_string (a_str: detachable READABLE_STRING_GENERAL) - -- Output Unicode string + -- Output Unicode string. do if a_str /= Void then to_implement ("Convert into UTF-8 or console encoding before output") @@ -51,7 +51,7 @@ feature -- Output end note - copyright: "2011-2012, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/utility/general/error/src/visitor/output_error_visitor.e b/library/utility/general/error/src/visitor/output_error_visitor.e index 50b05b3d..fb574e3b 100644 --- a/library/utility/general/error/src/visitor/output_error_visitor.e +++ b/library/utility/general/error/src/visitor/output_error_visitor.e @@ -14,12 +14,12 @@ inherit feature -- Output output_string (a_str: detachable READABLE_STRING_GENERAL) - -- Output Unicode string + -- Output Unicode string. deferred end output_any (obj: detachable ANY) - -- Output Unicode string + -- 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") @@ -42,6 +42,7 @@ feature -- Output feature -- Process process_error (e: ERROR) + -- do output_string ({STRING_32}"Error Name: ") output_string (e.name) @@ -54,6 +55,7 @@ feature -- Process end process_custom (e: ERROR_CUSTOM) + -- do output_string ({STRING_32}"Error Name: ") output_string (e.name) @@ -66,22 +68,19 @@ feature -- Process 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 + across + g.sub_errors as s loop - l_errors.item.process (Current) - l_errors.forth + s.item.process (Current) end end note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/utility/general/error/src/visitor/text_output_error_visitor.e b/library/utility/general/error/src/visitor/text_output_error_visitor.e index b79b1b75..0e565a01 100644 --- a/library/utility/general/error/src/visitor/text_output_error_visitor.e +++ b/library/utility/general/error/src/visitor/text_output_error_visitor.e @@ -16,7 +16,7 @@ inherit create make -feature -- Initialization +feature {NONE} -- Creation make (buf: like buffer) require @@ -32,7 +32,7 @@ feature -- Access feature -- Output output_string (a_str: detachable READABLE_STRING_GENERAL) - -- Output Unicode string + -- Output Unicode string. do if a_str /= Void then to_implement ("Convert into UTF-8 or console encoding before output") @@ -51,7 +51,7 @@ feature -- Output end note - copyright: "2011-2012, Eiffel Software and others" + copyright: "2011-2017, Jocelyn Fiat, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software