# Copyright 2005-2007 Kevin Reid, under the terms of the MIT X license # found at http://www.opensource.org/licenses/mit-license.html ................ pragma.syntax("0.9") pragma.enable("accumulator") def StructureException :DeepFrozen := def simplifyFQName :DeepFrozen := def defineExceptionGuard implements DeepFrozen, ExitViaHere { to run(matchTypeIDs :List[String]) { def idSet := matchTypeIDs.asSet() def exceptionGuard { to __printOn(out :TextWriter) { var sep := "" for x in matchTypeIDs { out.print(sep, simplifyFQName(x)) sep := "|" } } to coerce(specimen, optEjector) { def se := StructureException.coerce(specimen, optEjector) def type := se.__getAllegedType() if (accum false for super in type.getSupers() { _ | idSet.contains(super.getOptFQName()) }) { return se } else { throw.eject(optEjector, `exception $se doesn't match types $matchTypeIDs`) } } } return exceptionGuard } }