This site contains older material on Eiffel. For the main Eiffel page, see http://www.eiffel.com.

EiffelBase class
(HTML page generated by ISE Eiffel 4.2)

Eiffel Class
indexing
	description: "Facilities for adapting the exception handling mechanism. This class may be used as ancestor by classes needing its facilities.";
	status: "See notice at end of class";
	date: "$Date: 2007-03-30 11:10:11 -0800 (Fri, 30 Mar 2007) $";
	revision: "$Revision: 95354 $"

class EXCEPTIONS

inherit
	EXCEP_CONST

feature -- Status report

	meaning (except: INTEGER): STRING is
			-- A message in English describing what except is
		external
			"C | %"eif_except.h%""
		alias
			"eename"
		end;

	assertion_violation: BOOLEAN is
			-- Is last exception originally due to a violated
			-- assertion or non-decreasing variant?
		do
			Result := (original_exception = check_instruction) or else (original_exception = class_invariant) or else (original_exception = loop_invariant) or else (original_exception = loop_variant) or else (original_exception = postcondition) or else (original_exception = precondition)
		end;

	is_developer_exception: BOOLEAN is
			-- Is the last exception originally due to
			-- a developer exception?
		do
			Result := (original_exception = developer_exception)
		end;

	is_developer_exception_of_name (name: STRING): BOOLEAN is
			-- Is the last exception originally due to a developer
			-- exception of name name?
		do
			Result := is_developer_exception and then equal (name, developer_exception_name)
		end;

	developer_exception_name: STRING is
			-- Name of last developer-raised exception
		require
			applicable: is_developer_exception
		do
			Result := original_tag_name
		end;

	is_signal: BOOLEAN is
			-- Is last exception originally due to an external
			-- event (operating system signal)?
		do
			Result := (original_exception = signal_exception)
		end;

	is_system_exception: BOOLEAN is
			-- Is last exception originally due to an
			-- external event (operating system error)?
		do
			Result := (original_exception = external_exception) or else (original_exception = operating_system_exception)
		end;

	tag_name: STRING is
			-- Tag of last violated asssertion clause
		external
			"C | %"eif_except.h%""
		alias
			"eeltag"
		end;

	recipient_name: STRING is
			-- Name of the routine whose execution was
			-- interrupted by last exception
		external
			"C | %"eif_except.h%""
		alias
			"eelrout"
		end;

	class_name: STRING is
			-- Name of the class that includes the recipient
			-- of original form of last exception
		external
			"C | %"eif_except.h%""
		alias
			"eelclass"
		end;

	exception: INTEGER is
			-- Code of last exception that occurred
		external
			"C | %"eif_except.h%""
		alias
			"eelcode"
		end;

	exception_trace: STRING is
			-- String representation of the exception trace
		external
			"C | %"eif_except.h%""
		alias
			"stack_trace_string"
		end;

	original_tag_name: STRING is
			-- Assertion tag for original form of last
			-- assertion violation.
		external
			"C | %"eif_except.h%""
		alias
			"eeotag"
		end;

	original_exception: INTEGER is
			-- Original code of last exception that triggered
			-- current exception
		external
			"C | %"eif_except.h%""
		alias
			"eeocode"
		end;

	original_recipient_name: STRING is
			-- Name of the routine whose execution was
			-- interrupted by original form of last exception
		external
			"C | %"eif_except.h%""
		alias
			"eeorout"
		end;

	original_class_name: STRING is
			-- Name of the class that includes the recipient
			-- of original form of last exception
		external
			"C | %"eif_except.h%""
		alias
			"eeoclass"
		end;

feature -- Status setting

	catch (code: INTEGER) is
			-- Make sure that any exception of code code will be
			-- caught. This is the default.
		external
			"C | %"eif_except.h%""
		alias
			"eecatch"
		end;

	ignore (code: INTEGER) is
			-- Make sure that any exception of code code will be
			-- ignored. This is not the default.
		external
			"C | %"eif_except.h%""
		alias
			"eeignore"
		end;

	raise (name: STRING) is
			-- Raise a developer exception of name name.
		local
			str: ANY
		do
			if name /= void then
				str := name.to_c
			end;
			exclear;
			eraise ($str, developer_exception)
		end;

	die (code: INTEGER) is
			-- Terminate execution with exit status code,
			-- without triggering an exception.
		external
			"C | %"eif_except.h%""
		alias
			"esdie"
		end;

	new_die (code: INTEGER) is
		obsolete "Use ``die%'%'"
		external
			"C | %"eif_except.h%""
		alias
			"esdie"
		end;

	message_on_failure is
			-- Print an exception history table
			-- in case of failure.
			-- This is the default.
		do
			c_trace_exception (true)
		end;

	no_message_on_failure is
			-- Do not print an exception history table
			-- in case of failure.
		do
			c_trace_exception (false)
		end;

feature {NONE} -- Implementation

	exclear is
		external
			"C | %"eif_except.h%""
		end;

	eraise (str: POINTER; code: INTEGER) is
			-- Raise an exception
		external
			"C | %"eif_except.h%""
		end;

	c_trace_exception (b: BOOLEAN) is
		external
			"C | %"eif_except.h%""
		alias
			"eetrace"
		end;

end -- class EXCEPTIONS