class RepoError extends Error { constructor ( readonly type , message ) { super ( message ) ; } static InvalidArg ( argname , info = null ) { const infoStr = info ? `Expected '${ info . expected }', but got '${ info . got }'` : '' ; return new RepoError ( RepoError . Types . InvalidArgs , `Invalid '${ argname }' argument. ${ infoStr }` ) ; } static AlreadyExists ( message ) { return new RepoError ( RepoError . Types . AlreadyExists , message ) ; } static OnlyOne ( path , query ) { return new RepoError ( RepoError . Types . OnlyOne , `Requested query '${ query }' for path '${ path }' returned not the only item` ) ; } } namespace RepoError { export enum Types { Unknown , InvalidArgs , AlreadyExists , OnlyOne } } export default RepoError ;