Inspired by BulletProof React, .
I applied its codebase architecture concepts to thestructured, Twenty codebase. .
This article focuses only on the error handling strategies used in Twenty codebase. .
Approach
In part 1.0, I mentioned that Bulletproof React mentions three ways of error handling:
API errors
In app errors
Error tracking
In this article, I want to provide examples and references to how Twenty handled in-app errors. The approach we take is simple:
Pick onSubmit method in CreateProfile.tsx file. .
Review how the error is handled.
In this part 1.0, we review the onSubmit method in CreateProfile.tsx file. .
CreateProfile.tsx
CreateProfile modal is rendered during the onboarding on the twenty.com . platform, we will review the onSubmit method:
const onSubmit : SubmitHandler < Form > = useCallback ( async ( data ) => { try { if ( ! currentWorkspaceMember ?. id ) { throw new Error ( ' User is not logged in ' ); } if ( ! data . firstName || ! data .…