Assets/Scripts/Wallet/CoroutineUtils.cs
/// <summary>
/// Run an iterator function that might throw an exception. Call the callback with the exception
/// if it does or null if it finishes without throwing an exception.
/// </summary>
/// <param name="enumerator">Iterator function to run</param>
/// <param name="done">Callback to call when the iterator has thrown an exception or finished.
/// The thrown exception or null is passed as the parameter.</param>
/// <returns>An enumerator that runs the given enumerator</returns>
Run an iterator function that might throw an exception. Call the callback with the exception
if it does or null if it finishes without throwing an exception.
Run an iterator function that might throw an exception . Call the callback with the exception if it does or null if it finishes without throwing an exception .
public static IEnumerator RunThrowingIterator(
		IEnumerator enumerator,
		Action<Exception> done
	)
	{
		while (true)
		{
			object current;
			try
			{
				if (enumerator.MoveNext() == false)
				{
					break;
				}
				current = enumerator.Current;
			}
			catch (Exception ex)
			{
				done(ex);
				yield break;
			}
			yield return current;
		}
		done(null);
	}
public static IEnumerator RunThrowingIterator ( IEnumerator enumerator , Action < Exception > done ) { while ( true ) { object current ; try { if ( enumerator . MoveNext ( ) == false ) { break ; } current = enumerator . Current ; } catch ( Exception ex ) { done ( ex ) ; yield break ; } yield return current ; } done ( null ) ; }
Run an iterator function that might throw an exception.
Run an iterator function that might throw an exception .
An enumerator that runs the given enumerator
An enumerator that runs the given enumerator
enumerator
IEnumerator
Iterator function to run
Iterator function to run
done
Action<Exception>
Callback to call when the iterator has thrown an exception or finished.
The thrown exception or null is passed as the parameter.
Callback to call when the iterator has thrown an exception or finished . The thrown exception or null is passed as the parameter .