

- #Visual prolog expression is used when a formula is expected how to
- #Visual prolog expression is used when a formula is expected code
- #Visual prolog expression is used when a formula is expected plus
#Visual prolog expression is used when a formula is expected code
Raise_cannotCreate_explicit is called with the ProgramPoint of the raising predicate, the FileName and the windows error code LastError that the relevant low level Windows API predicate caused.Įxception :: getLastErrorDescription obtains the description corresponding to LastError from Windows.Įxception :: raise_definiteUser_explict is then used to raise the cannotCreate exception with the four pieces of extra information. NamedValue (errorDescription_parameter, string ( Desc ) ) ] ). NamedValue (errorCode_parameter, unsigned ( LastError ) ) , NamedValue (fileSystem_path_parameter, string (directory :: getCurrentDirectory ( ) ) ) , Raise_definiteUser_explicit ( ProgramPoint, cannotCreate, Msg, [namedValue (fileSystem_fileName_parameter, string ( FileName ) ) , Raise_cannotCreate_explicit ( ProgramPoint, FileName, LastError ) :- Desc = getLastErrorDescription ( LastError ), Msg = string :: format ( "Cannot create or open '%%%s' \nError = 0x%08x \n%%%s" ,įileSystem_fileName_parameter, LastError, errorDescription_parameter ) , If nothing else handles an exception it will (normally) be handled by the fallback/default handler of the program.Īn exception is a value of the type core :: exception When the exception is raised and each time it is continued extra information can be added to the exception trace.
#Visual prolog expression is used when a formula is expected plus
When an exception is continued it consists of the original exception plus some continue information. In this case the best thing the handler code can do is to continue the exception as an unknown exception (i.e.

#Visual prolog expression is used when a formula is expected how to
Especially, it may be an exception that the handler does not know how to handle. If it is another kind of exception the handler will have to do something different. So for the "write-protected" exception the handler code should write a message to the user.

The result of the handler code will be the result of the try-catch construction, and thus of saveInfo.the code between do and end try) is evaluated TraceId will be bound to the (so called) trace id, which is a handle to information about the exception (described in more details below).The code works like this: writeInfo is called, if it succeeds the try-catch construction will not do more and saveInfo will also succeed.īut in the write-protected case outputStream_file :: create will raise an exception and therefore the following will take place: WriteInfo ( Filename ) catch TraceId do % > end try. To set a handler we use the try-catch language construction: But from the program's point of view the exceptional situation is handled. The user can choose a different filename, remove the write protection, delete the file, cancel the operation entirely or something else. So the handling we want is simply to tell the user that the information was not written because the file was write-protected. In this case writeInfo is called after the user have entered the file name in a dialog and pressed a Save-button. When an exception is raised the program control is transferred to the nearest exception handler, which can hopefully handle the situation and thus bring the program back on track again. In outputStream_file :: create this situation is considered to be exceptional/unexpected and therefore it raises an exception. WriteInfo ( Filename ) :- S = outputStream_file :: create ( Filename ) ,īut if the file already exists and is write-protected it is impossible to create the stream.
