Exception Handling under IIB :-
The tree will be like as follows :-
ExceptionList------->RecoverableException
--->RecoverableException
--->RecoverableException
-->File
-->Line
-->Function
-->Type
-->Name
-->Label
-->Catalog
-->Severity
-->Number
-->Text
-->Insert
-->Type
-->Text
-->ParserException
-->File
-->Line
-->Function
-->Type
-->Name
-->Label
-->Catalog
-->Severity
-->Number
-->Text
-->Insert
-->Type
-->Text
Likewise tree will generate the ExceptionList...
MostLikely the LastChild of the ExceptionList tree will be the current Exception that is thrown by the respective node
Exception Class under IIB :-
Fatal
Recoverable
Configuration
Parser
Conversion
User
Database
How to access the above tree in ESQL code :-
So below are the code by which you can access the ExceptionList tree last exact Exception type and text ....
------------------------------------------------------------------------------------------------
DECLARE envarea REFERENCE TO Environment;
DECLARE exceptionList REFERENCE TO ExceptionList;
CREATE PROCEDURE getExceptionDescription ( IN envarea REFERENCE,IN exceptionList REFERENCE)
BEGIN
DECLARE errDescRef REFERENCE TO exceptionList.*[1];
DECLARE X INTEGER;
DECLARE I INTEGER 1;
DECLARE TXT CHARACTER '';
WHILE LASTMOVE(errDescRef) DO
IF FIELDNAME(errDescRef.Number) IS NOT NULL THEN
SET envarea.ErrorNumber=errDescRef.Number;
SET envarea.Errortype=FIELDNAME(errDescRef);
--
-- SET X = (CARDINALITY (errDescRef.Insert[]));
-- IF X >0 THEN
-- WHILE I < X +1 DO
-- DECLARE TEMP CHARACTER errDescRef.Insert[I].Text;
-- SET TXT = TXT || '[' || TEMP || ']';
-- SET I = I + 1;
-- END WHILE;
-- END IF;
-- SET envarea.ErrorText = TXT;
IF envarea.ErrorType = 'DatabaseException' THEN
SET envarea.SQLCode = errDescRef.Insert[2].Text;
END IF;
IF envarea.ErrorType = 'UserException' THEN
SET envarea.ErrorText=errDescRef.Text||'. Exception : '||errDescRef.Insert.Text;
END IF;
END IF;
MOVE errDescRef LASTCHILD;
END WHILE;
END;
-----------------------------------------------------------------------------------------------------------
The tree will be like as follows :-
ExceptionList------->RecoverableException
--->RecoverableException
--->RecoverableException
-->File
-->Line
-->Function
-->Type
-->Name
-->Label
-->Catalog
-->Severity
-->Number
-->Text
-->Insert
-->Type
-->Text
-->ParserException
-->File
-->Line
-->Function
-->Type
-->Name
-->Label
-->Catalog
-->Severity
-->Number
-->Text
-->Insert
-->Type
-->Text
Likewise tree will generate the ExceptionList...
MostLikely the LastChild of the ExceptionList tree will be the current Exception that is thrown by the respective node
Exception Class under IIB :-
Fatal
Recoverable
Configuration
Parser
Conversion
User
Database
How to access the above tree in ESQL code :-
So below are the code by which you can access the ExceptionList tree last exact Exception type and text ....
------------------------------------------------------------------------------------------------
DECLARE envarea REFERENCE TO Environment;
DECLARE exceptionList REFERENCE TO ExceptionList;
CREATE PROCEDURE getExceptionDescription ( IN envarea REFERENCE,IN exceptionList REFERENCE)
BEGIN
DECLARE errDescRef REFERENCE TO exceptionList.*[1];
DECLARE X INTEGER;
DECLARE I INTEGER 1;
DECLARE TXT CHARACTER '';
WHILE LASTMOVE(errDescRef) DO
IF FIELDNAME(errDescRef.Number) IS NOT NULL THEN
SET envarea.ErrorNumber=errDescRef.Number;
SET envarea.Errortype=FIELDNAME(errDescRef);
--
-- SET X = (CARDINALITY (errDescRef.Insert[]));
-- IF X >0 THEN
-- WHILE I < X +1 DO
-- DECLARE TEMP CHARACTER errDescRef.Insert[I].Text;
-- SET TXT = TXT || '[' || TEMP || ']';
-- SET I = I + 1;
-- END WHILE;
-- END IF;
-- SET envarea.ErrorText = TXT;
IF envarea.ErrorType = 'DatabaseException' THEN
SET envarea.SQLCode = errDescRef.Insert[2].Text;
END IF;
IF envarea.ErrorType = 'UserException' THEN
SET envarea.ErrorText=errDescRef.Text||'. Exception : '||errDescRef.Insert.Text;
END IF;
END IF;
MOVE errDescRef LASTCHILD;
END WHILE;
END;
-----------------------------------------------------------------------------------------------------------
Thanks For reading ....If u like this blog than please Comments and Like .........