//==================================================================== // Internal helper methods for common error handling scenarios. //==================================================================== /// <summary> /// Raises a <see cref="TypeError"/> and attaches any existing exception as its cause. /// </summary> /// <param name="message">The exception message</param> /// <returns><c>null</c></returns> internal static NewReference RaiseTypeError(string message) { var cause = PythonException.FetchCurrentOrNullRaw(); cause?.Normalize(); Exceptions.SetError(Exceptions.TypeError, message); if (cause is null) { return(default);
//==================================================================== // Internal helper methods for common error handling scenarios. //==================================================================== /// <summary> /// Raises a <see cref="TypeError"/> and attaches any existing exception as its cause. /// </summary> /// <param name="message">The exception message</param> /// <returns><c>null</c></returns> internal static NewReference RaiseTypeError(string message) { var cause = PythonException.FetchCurrentOrNullRaw(); cause?.Normalize(); Exceptions.SetError(Exceptions.TypeError, message); if (cause is null) return default; var typeError = PythonException.FetchCurrentRaw(); typeError.Normalize(); Runtime.PyException_SetCause( typeError.Value!, new NewReference(cause.Value!).Steal()); typeError.Restore(); return default; }