reclaimprotocol / reclaim-js-sdk

JavaScript SDK for easy integration of Reclaim Protocol that enables authenticated web data export via HTTPS and zero-knowledge proofs
25 stars 4 forks source link

Improve and Standardize Error Handling and Logging Strategy #6

Open AbdulRashidReshamwala opened 1 month ago

AbdulRashidReshamwala commented 1 month ago

Improve and Standardize Error Handling and Logging Strategy

Description

While we already use pino for logging in our SDK, our error handling approach is inconsistent across the codebase. We need to standardize our error handling and improve our use of the existing logging system to enhance debugging, error reporting, and overall reliability of the SDK. Some error messages donot provide the entire context on what caused the issue and what action user to take to solve the issue.

//eg: does not give us the entire information what can cause the identifier mismatch 
//and there are no logs showing what is the expected identifier and what was the indetifier that was calculated
throw new ProofNotVerifiedError('Identifier Mismatch')

Goals

Current State

We currently use pino for logging:

Girishbari commented 1 month ago

let me handle this

Girishbari commented 1 month ago

Hey @AbdulRashidReshamwala I can see the first 2 major goals are already implemented I can observe in the codebase there is already a custom handling mechanism and most of all files have a logger for log extra info, I can observe there might be need for custom error types and improve existing error message.

So do you want me to go into that or maybe I am entirely wrong with my observation and we need to achieve all the listed goals

Kushal7788 commented 1 month ago

Hi @Girishbari. We have moved to a custom implementation of logging. We are no longer using pino. Currently across all the files we are using info logs. We need to segregate these logs based on the type of information we want to convey to the user. New goals are as follows

  1. Add logs according to the level (error - when we get an exceptions or errors, info - to get relevant details as users call different methods, warn - when some data is not present or may lead to an error if not corrected, etc) across the SDK
  2. Add more detail custom error messages which are user friendly and convey relevant information to resolve the errors.
Girishbari commented 1 month ago

Yeah this can be done

Girishbari commented 1 month ago

hi @Kushal7788 I revalidated both points I have added proper logs message type wherever required and there are already good error messages provided. Which conveys proper suggestion and error message and also provides most probable solution although I made few tweaks here and there PR #14

Girishbari commented 3 weeks ago

Hi @Kushal7788, there are validation methods for respective public methods then why codebase is only using validateFunctionParams