MaximumSubscribersReachedException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.StreamName)?.Value,
Constants.Exceptions.StreamNotFound => new StreamNotFoundException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.StreamName)?.Value, ex),
PersistentSubscriptionNotFoundException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.StreamName)?.Value,
Constants.Exceptions.StreamDeleted => new StreamDeletedException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.StreamName)?.Value ?? "<unknown>",
Constants.Exceptions.WrongExpectedVersion => new WrongExpectedVersionException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.StreamName)?.Value,
Constants.Exceptions.ScavengeNotFound => new ScavengeNotFoundException(ex.Trailers .FirstOrDefault(x => x.Key == Constants.Exceptions.ScavengeId)?.Value),
RequiredMetadataPropertyMissingException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.MissingRequiredMetadataProperty) ?.Value, ex),
Constants.Exceptions.UserNotFound => new UserNotFoundException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.LoginName)?.Value),
PersistentSubscriptionDroppedByServerException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.StreamName)?.Value,
[Constants.Exceptions.NotLeader] = ex => new NotLeaderException( ex.Trailers.FirstOrDefault(x => x.Key == Constants.Exceptions.LeaderEndpointHost)?.Value !,