Closed Harman-singh-waraich closed 1 month ago
The changes in this pull request enhance error handling and session verification in the AtlasProvider
component and related functions. A new asynchronous function, fetchWithAuthErrorHandling
, is introduced to manage authorization errors. The session verification logic is refactored from an interval-based to a timeout-based approach. Additionally, the addUser
, updateEmail
, and uploadFile
methods are updated to utilize the new error handling mechanism. A new AuthorizationError
class is created to handle specific authorization issues, improving overall error specificity.
File Path | Change Summary |
---|---|
web/src/context/AtlasProvider.tsx | Added fetchWithAuthErrorHandling for error handling; refactored session verification logic to timeout-based. |
web/src/utils/atlas/addUser.ts | Enhanced error handling in addUser to throw GraphQLError with details on failure. |
web/src/utils/atlas/updateEmail.ts | Improved error handling in updateEmail to throw GraphQLError with details; added GraphQLError import. |
web/src/utils/atlas/uploadToIpfs.ts | Introduced AuthorizationError class; modified uploadToIpfs to throw AuthorizationError on 401 status. |
Objective | Addressed | Explanation |
---|---|---|
Optimize session verification strategy in AtlasProvider (#1717) | β |
addUser
, updateEmail
, and other user-related functions, which are also updated in the main PR to utilize the new error handling function in AtlasProvider.tsx
.uploadFile
method in AtlasProvider
, which is directly connected to the changes made in the main PR regarding error handling and session verification, as well as the use of the uploadToIpfs
function.SubmitEvidenceModal
, which is relevant to the main PR's focus on enhancing error handling across user operations, including those in the AtlasProvider
.Priority: High
, Type: FeatureπΏ
, Package: Web
π° "In the garden where the code does grow,
Error handling now shines with a glow.
Sessions verified, no more delay,
With each hop, we improve our way.
Authorization clear, no more fright,
Hooray for changes, all feels right!" π
Name | Link |
---|---|
Latest commit | a85995823389bb96a1d6e06b73f5efcf84839d2e |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-testnet/deploys/6720962d20375000087cddad |
Deploy Preview | https://deploy-preview-1727--kleros-v2-testnet.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Name | Link |
---|---|
Latest commit | a85995823389bb96a1d6e06b73f5efcf84839d2e |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-university/deploys/6720962d035448000852a5c9 |
Deploy Preview | https://deploy-preview-1727--kleros-v2-university.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Name | Link |
---|---|
Latest commit | a85995823389bb96a1d6e06b73f5efcf84839d2e |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-testnet-devtools/deploys/6720962d60db300008b2fb3e |
Deploy Preview | https://deploy-preview-1727--kleros-v2-testnet-devtools.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Name | Link |
---|---|
Latest commit | a85995823389bb96a1d6e06b73f5efcf84839d2e |
Latest deploy log | https://app.netlify.com/sites/kleros-v2-neo/deploys/6720962de2dda20008ed3f67 |
Deploy Preview | https://deploy-preview-1727--kleros-v2-neo.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Looks great, I left some small notes and have a question: how is state managed across tabs/app reloads? The current approach seems to work (I've not run the code), but I want to check that the
setTimeout
will be reestablished on those conditions.
Session is linked to a tab, changing tabs would require to SignIn again. On reloads, there is an useEffect that does an initial session verification and then schedules the next verification. Which handles the reload cases.
Let me know if this answers your doubt :v:
Code Climate has analyzed commit a8599582 and detected 1 issue on this pull request.
Here's the issue category breakdown:
Category | Count |
---|---|
Style | 1 |
View more on Code Climate.
Failed conditions
17.6% Duplication on New Code (required β€ 10%)
closes #1717
PR-Codex overview
This PR focuses on improving error handling and authorization checks in the application, specifically when interacting with IPFS and GraphQL. It introduces a new
AuthorizationError
class and enhances existing functions to better manage authentication-related errors.Detailed summary
AuthorizationError
class inuploadToIpfs.ts
.addUser
andupdateEmail
functions to throwGraphQLError
for specific errors.AtlasProvider
to include a newfetchWithAuthErrorHandling
function for handling requests with authorization checks.Summary by CodeRabbit
New Features
AuthorizationError
class for better error specificity.Bug Fixes
addUser
andupdateEmail
functions to provide more detailed error messages.Refactor