diff --git a/waku/waku_keystore/conversion_utils.nim b/waku/waku_keystore/conversion_utils.nim index c19044cbd5..4a76811114 100644 --- a/waku/waku_keystore/conversion_utils.nim +++ b/waku/waku_keystore/conversion_utils.nim @@ -18,6 +18,16 @@ proc decode*(encodedCredential: seq[byte]): KeystoreResult[KeystoreMembership] = let jsonObject = parseJson(string.fromBytes(encodedCredential)) return ok(to(jsonObject, KeystoreMembership)) except JsonParsingError: - return err(AppKeystoreError(kind: KeystoreJsonError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreJsonError, + msg: "error during decoding credentials: " & getCurrentExceptionMsg(), + ) + ) except Exception: #parseJson raises Exception - return err(AppKeystoreError(kind: KeystoreOsError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreOsError, + msg: "error in conversion_utils decode: " & getCurrentExceptionMsg(), + ) + ) diff --git a/waku/waku_keystore/keystore.nim b/waku/waku_keystore/keystore.nim index d79844b084..9741761ff7 100644 --- a/waku/waku_keystore/keystore.nim +++ b/waku/waku_keystore/keystore.nim @@ -31,7 +31,12 @@ proc createAppKeystore*( f.write(separator) ok() except CatchableError: - err(AppKeystoreError(kind: KeystoreOsError, msg: getCurrentExceptionMsg())) + err( + AppKeystoreError( + kind: KeystoreOsError, + msg: "error while writing keystore: " & getCurrentExceptionMsg(), + ) + ) finally: f.close() @@ -114,19 +119,43 @@ proc loadAppKeystore*( return ok(data) # TODO: we might continue rather than return for some of these errors except JsonParsingError: - return - err(AppKeystoreError(kind: KeystoreJsonError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreJsonError, + msg: + "error during loading keystore, JsonParsingError: " & + getCurrentExceptionMsg(), + ) + ) except ValueError: - return - err(AppKeystoreError(kind: KeystoreJsonError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreJsonError, + msg: + "error during loading keystore, ValueError: " & getCurrentExceptionMsg(), + ) + ) except OSError: - return - err(AppKeystoreError(kind: KeystoreOsError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreOsError, + msg: "error during loading keystore, OSError: " & getCurrentExceptionMsg(), + ) + ) except Exception: #parseJson raises Exception - return - err(AppKeystoreError(kind: KeystoreOsError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreOsError, + msg: "error during loading keystore, Exception: " & getCurrentExceptionMsg(), + ) + ) except IOError: - return err(AppKeystoreError(kind: KeystoreIoError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreIoError, + msg: "error during loading keystore, IOError: " & getCurrentExceptionMsg(), + ) + ) return err( AppKeystoreError( diff --git a/waku/waku_keystore/utils.nim b/waku/waku_keystore/utils.nim index 88c10207e2..bbfbf31cb0 100644 --- a/waku/waku_keystore/utils.nim +++ b/waku/waku_keystore/utils.nim @@ -30,7 +30,12 @@ proc save*(json: JsonNode, path: string, separator: string): KeystoreResult[void # We save the updated json var f: File if not f.open(path, fmAppend): - return err(AppKeystoreError(kind: KeystoreOsError, msg: getCurrentExceptionMsg())) + return err( + AppKeystoreError( + kind: KeystoreOsError, + msg: "error in waku_keystore save: " & getCurrentExceptionMsg(), + ) + ) try: # To avoid other users/attackers to be able to read keyfiles, we make the file readable/writable only by the running user setFilePermissions(path, {fpUserWrite, fpUserRead})