Skip to content

Instantly share code, notes, and snippets.

View MoaidHathot's full-sized avatar
🏠
Working from home

Moaid Hathot MoaidHathot

🏠
Working from home
View GitHub Profile
@MoaidHathot
MoaidHathot / TryCatchExtensions.cs
Last active July 27, 2024 00:19
Demonstrating a "TryCatch" Extension method over IEnumerable
using Dumpify;
Enumerable.Range(0, 10)
.Where(i => i % 2 == 0)
.Select(i => i == 6 ? throw new Exception("Oops") : i)
.Select(i => i * 2)
.CatchExceptions(ex => ex.Dump())
.Dump();
public static class TryCatchExtensions
@MoaidHathot
MoaidHathot / TryCatchExtensions2.cs
Last active July 27, 2024 17:29
Demonstrating a "TryCatch" Extension method over IEnumerable, this version with more ValueTuples
using Dumpify;
Enumerable.Range(0, 10)
.Where(i => i % 2 == 0)
.Select(i => i == 6 ? throw new Exception("Oops") : i)
.Select(i => i * 2)
.CatchExceptions(ex => ex.Dump())
.Dump();
public static class TryCatchExtensions