import { ErrorCodes , ITkeyError , TkeyError } from "@tkey/common-types" ; class WebStorageError extends TkeyError { protected static messages : ErrorCodes = { 3000 : "default" , 3101 : "unableToReadFromStorage" , 3201 : "No Share exists in file system" , 3202 : "No requestFileSystem" , 3301 : "Local storage is not enabled" , 3302 : "No share exists in localstorage" , } ; code : number ; message : string ; public constructor ( code , message ? ) { super ( code , message ) ; Object . defineProperty ( this , "name" , { value : "WebStorageError" } ) ; } public static fromCode ( code , extraMessage = "" ) { return new WebStorageError ( code , `${ WebStorageError . messages [ code ] }${ extraMessage }` ) ; } public static default ( extraMessage = "" ) { return new WebStorageError ( 3000 , `${ WebStorageError . messages [ 3000 ] }${ extraMessage }` ) ; } public static unableToReadFromStorage ( extraMessage = "" ) { return WebStorageError . fromCode ( 3101 , extraMessage ) ; } public static shareUnavailableInFileStorage ( extraMessage = "" ) { return WebStorageError . fromCode ( 3201 , extraMessage ) ; } public static fileStorageUnavailable ( extraMessage = "" ) { return WebStorageError . fromCode ( 3202 , extraMessage ) ; } public static localStorageUnavailable ( extraMessage = "" ) { return WebStorageError . fromCode ( 3301 , extraMessage ) ; } public static shareUnavailableInLocalStorage ( extraMessage = "" ) { return WebStorageError . fromCode ( 3302 , extraMessage ) ; } } export default WebStorageError ;