oslofjord / sanity-linq

Strongly-typed .Net Client for Sanity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use custom exception types

KennethHoff opened this issue · comments

I noticed that in various places (GitHub search) you are throwing the base Exception type, which is not recommended.

Would it be possible to create a custom base Exception like SanityException and whenever you throw, throw an Exception that derives from it?

Here for example, you could throw a SanitySerializationException such that we - as a consumer of this library - can utilize the catch (SanityException ex) or catch (SanitySerializationException ex) syntaxes.

catch (Exception ex)
{
throw new Exception($"Failed to deserialize Sanity response: {content}", ex);
}