Download PDF file (1425K characters)
Transcript
Chapter 4: Mail Filtering Language 97 global exception handlers in a begin statement (see Section 4.12 [begin/end], page 71). When used within a usual function or handler, the exception handlers set by a standalone catch remain in force until either another standalone catch appears further in the same function or handler, or an end of the function is encountered, whichever occurs first. A standalone catch defined within a function must return from it by executing return statement. If it does not do that explicitly, the default value of 1 is returned. A standalone catch defined within a milter handler must end execution with any of the following actions: accept, continue, discard, reject, tempfail. By default, continue is used. It is not recommended to mix ‘try--catch’ constructs and standalone catches. If a standalone catch appears within a ‘try--catch’ statement, its scope of visibility is undefined. Upon entry to a handler-body, two implicit positional arguments are defined, which can be referenced in handler-body as $1 and $2. The first argument gives the numeric code of the exception that has occurred. The second argument is a textual string containing a human-readable description of the exception. The following is an improved version of the previous example, which uses these parameters to supply more information about the failure: try do if primitive_hasmx(domainpart($f)) accept else reject fi done catch e_failure or e_temp_failure do echo "Caught exception $1: $2" continue done The following example defines the function hasmx that returns true if the domain part of its argument has any ‘MX’ records, and false if it does not or if an exception occurs7 . func hasmx (string s) returns number do try do return primitive_hasmx(domainpart(s)) done catch * do return 0 7 This function is part of the mailfromd library, See [hasmx], page 133.