class predicates handle File Error:( exception: traceID ErrorCode )failure clauses handle File Read Error(ErrorCode) Descriptor exception: try GetDescriptor(ErrorCode, file System_api: cannotcreate ) i file cannot be loaded exception: descriptor(ErrorCode, %_ErrorCode is Errorcode %just not necessary to insert extra check here ClassInfo, class information of the class, which raised the exception Exception, actually it is file System_api: cannotcreate, Yo but the parameter should not be compared by %o See exception State: equals Kind, exception can be raised or continued ExtraInfo CursorPosition %o currently we know the position but sending dumps to developers requires positions GMTTime, %o the time of exception creation ExceptionDescription )= Descriptor, File Name core: mapLookUp(ExtraInfo file System_ api: file Name_parameter, string ()) common_exception: errorDescription_parameter, string(")). stdIo: write("Cannot load file due to: " Exception Des cription, AnFile Name: File Name n:,Reason) exception: clear(ErrorCode) %o it is necessary to clean exceptions when they are handled handle File Read Error(ErrorCode): Debug Mode true , exception Dump: dump ToStdOutput(ErrorCode), %o dump to console for developer needs exception: clearAllO, Yo clear all exce ptions, as they are shown in the dump already fail handle File Read Error(ErrorCode): exception: clear(Errorcode), %o program cannot handle the exce ption and it does not report about it fail
class predicates handleFileReadError : ( exception::traceID ErrorCode ) failure. clauses handleFileReadError(ErrorCode):- Descriptor = exception::tryGetDescriptor(ErrorCode, fileSystem_api::cannotcreate), !, % file cannot be loaded exception::descriptor(_ErrorCode, % _ErrorCode is ErrorCode , %just not necessary to insert extra check here _ClassInfo, % class information of the class, which raised the exception . _Exception, % actually it is fileSystem_api::cannotcreate, % but the parameter should not be compared by ' = ' . % See exceptionState::equals _Kind, % exception can be raised or continued ExtraInfo, _CursorPosition, % currently we know the position, % but sending dumps to developers requires positions _GMTTime, % the time of exception creation . ExceptionDescription) = Descriptor, FileName = core::mapLookUp(ExtraInfo, fileSystem_api::fileName_parameter, string("")), Reason = core::mapLookUp(ExtraInfo, common_exception::errorDescription_parameter, string("")), stdIO::write("Cannot load file due to: ",ExceptionDescription, "\nFileName: ", FileName, "\nReason: ", Reason ), exception::clear(ErrorCode), % it is necessary to clean exceptions when they are handled fail. handleFileReadError(ErrorCode):- isDebugMode = true, !, exceptionDump::dumpToStdOutput(ErrorCode), % dump to console for developer needs exception::clearAll(), % clear all exceptions, as they are shown in the dump already . fail. handleFileReadError(ErrorCode):- exception::clear(ErrorCode), % program cannot handle the exception and it does not report about it . fail