Python.Runtime.Exceptions.ErrorOccurred C# (CSharp) Method

ErrorOccurred() public static method

ErrorOccurred Method
Returns true if an exception occurred in the Python runtime. This is a wrapper for the Python PyErr_Occurred call.
public static ErrorOccurred ( ) : bool
return bool
        public static bool ErrorOccurred()
        {
            return Runtime.PyErr_Occurred() != 0;
        }

Usage Example

Example #1
0
        protected override void OnSave(InterDomainContext context)
        {
            base.OnSave(context);
            System.Diagnostics.Debug.Assert(dict == GetObjectDict(pyHandle));
            foreach (var attr in cache.Values)
            {
                Runtime.XIncref(attr.pyHandle);
            }
            // Decref twice in tp_clear, equilibrate them.
            Runtime.XIncref(dict);
            Runtime.XIncref(dict);
            // destroy the cache(s)
            foreach (var pair in cache)
            {
                if ((Runtime.PyDict_DelItemString(DictRef, pair.Key) == -1) &&
                    (Exceptions.ExceptionMatches(Exceptions.KeyError)))
                {
                    // Trying to remove a key that's not in the dictionary
                    // raises an error. We don't care about it.
                    Runtime.PyErr_Clear();
                }
                else if (Exceptions.ErrorOccurred())
                {
                    throw new PythonException();
                }
                pair.Value.DecrRefCount();
            }

            cache.Clear();
        }
All Usage Examples Of Python.Runtime.Exceptions::ErrorOccurred