export class EarthstarError extends Error { constructor(message?: string) { super(message || ""); this.name = "EarthstarError"; }}
export class ValidationError extends EarthstarError { constructor(message?: string) { super(message || "Validation error"); this.name = "ValidationError"; }}
export class ReplicaIsClosedError extends EarthstarError { constructor(message?: string) { super( message || "a Replica or ReplicaDriver was used after being closed", ); this.name = "ReplicaIsClosedError"; }}
export class ReplicaCacheIsClosedError extends EarthstarError { constructor(message?: string) { super( message || "a ReplicaCache was used after being closed", ); this.name = "ReplicaCacheIsClosedError"; }}
export class QueryFollowerIsClosedError extends EarthstarError { constructor(message?: string) { super(message || "a QueryFollower was used after being closed"); this.name = "QueryFollowerIsClosedError"; }}
export class NotFoundError extends EarthstarError { constructor(message?: string) { super(message || "not found"); this.name = "NotFoundError"; }}
export class NetworkError extends EarthstarError { constructor(message?: string) { super(message || "network error"); this.name = "NetworkError"; }}
export class TimeoutError extends EarthstarError { constructor(message?: string) { super(message || "timeout error"); this.name = "TimeoutError"; }}
export class ConnectionRefusedError extends EarthstarError { constructor(message?: string) { super(message || "connection refused"); this.name = "ConnectionRefused"; }}
export class NotImplementedError extends EarthstarError { constructor(message?: string) { super(message || "not implemented yet"); this.name = "NotImplementedError"; }}
export function isErr<T>(x: T | Error): x is EarthstarError { return x instanceof EarthstarError;}
export function notErr<T>(x: T | Error): x is T { return !(x instanceof EarthstarError);}