Consensys / starknet-snap

The MetaMask Snap for Starknet
https://snaps.consensys.net/starknet
Apache License 2.0
74 stars 26 forks source link

refactor: add error utils #307

Closed stanleyyconsensys closed 1 month ago

stanleyyconsensys commented 1 month ago

This PR is to add an error utils to check if the error is an Snap Error

This PR can be combine to use with this PR https://github.com/Consensys/starknet-snap/pull/305 When validate request is throwing an Snap Error, and we should not hide the validation error by checking if the error is an snap error or not

possible use case

try {
   validateRequest(params, struct)
} catch (error) {
   if (isSnapRpcError(error) {
       throw error
   }
   throw new SnapError('masked error message')
}
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-wallet-ui'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed for 'consensys_starknet-snap-starknet-snap'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud