public ExceptionMapping(string python, string module, Type clr) { pythonException = python; pythonModule = module; clrException = clr; this.subtypes = null; creator = ExceptionConverter.DefaultExceptionCreator; }
public ExceptionMapping(string python, Type clr, ExceptionClassCreator creator) { pythonException = python; pythonModule = ExceptionConverter.defaultExceptionModule; clrException = clr; this.subtypes = null; this.creator = creator; }
public ExceptionMapping(string python, Type clr, ExceptionMapping[] subtypes) { pythonException = python; pythonModule = ExceptionConverter.defaultExceptionModule; clrException = clr; this.subtypes = subtypes; creator = ExceptionConverter.DefaultExceptionCreator; }
/// <summary> /// Creates and returns the IPythonType for a given PythonException in a given module with a given base type using a given exception creator. /// Throws InvalidOperationException if it already exists and has a different base type. /// /// Note that specifying the module doesn't actually place the created type in that module. /// The type knows about the module, but the module doesn't know about the type. It's the caller's /// responsibility to put the returned type in the appropriate module. /// </summary> public static IPythonType CreatePythonException(string name, string module, IPythonType baseType, ExceptionClassCreator creator) { IPythonType type; QualifiedExceptionName key = new QualifiedExceptionName(name, module); if (nameToPython.TryGetValue(key, out type)) { if (Ops.Equals(type.BaseClasses, ObjectToTuple(baseType))) { return type; } else { throw new InvalidOperationException(module + "." + name + " already exists with different base type(s)"); } } IPythonType res = creator(name, module, baseType); nameToPython[key] = res; return res; }