How do I raise an exception further in eiffel? I have 3 cases
I want to retry
a_feature
local
l_retries_count: INTEGER
do
some_potential_failing_feature
rescue
if l_retries_count <= 3 then
l_retries_count := l_retries_count + 1
retry
end
end
I want to do close db connection and ignore exception
a_feature
do
some_potential_failing_feature
rescue
db_connection.close
end
I want to do close db connection and send an email to an admin and ignore
a_feature
do
some_potential_failing_feature
rescue
db_connection.close
send_email_to_admin
end
I want to close db_connection and raise the exception further, I'll put all the cases I can think about into the above code
a_feature
local
l_retries_count: INTEGER
do
some_potential_failing_feature
rescue
if l_retries_count <= 3 then
l_retries_count := l_retries_count + 1
log_error ("Error, retrying for " + l_retries_count.out + "th time")
retry
else
db_connection.close
send_email_to_admin
-- raise the_created_exception_from_some_potential_failing_feature -- how do I do that?
end
end
You can try one of the following:
{EXCEPTION_MANAGER}.last_exception.original.raise
{EXCEPTION_MANAGER}.last_exception.cause.raise
{EXCEPTION_MANAGER}.last_exception.raise
The first one goes through the chain of exceptions ignoring those triggered as a result of failed routines. It might be the one you are looking for.
The next two retrieve either the cause of the current exception or the current exception itself, though it might be not the one you are looking for because it depends on the context of the exception and the nested calls.