A filter block is declared using the filter keyword.
SEHClause ::= … |
---|
| filter Label HandlerBlock |
| filter Scope HandlerBlock |
The filter code begins at the specified label and ends at the first instruction of the handler block. (Note that the CLI demands that the filter block shall immediately precede, within the CIL stream, its corresponding handler block.)
[Example:
.method public static void m () {
.try {
… // protected instructions
leave exitSEH // normal exit
}
filter {
… // decide whether to handle
pop // pop exception object
ldc.i4.1 // EXCEPTION_EXECUTE_HANDLER
endfilter // return answer to CLI
}
{
… // handle the exception
pop // pop the exception object
leave exitSEH // leave filter handler
}
exitSEH:
…
}
end example]