File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,25 @@ const AddContactModal = ({
158158 setOIDC ( e . target . value ) ;
159159 } ;
160160
161+ const getUserFriendlyError = ( e ) => {
162+ const status = e ?. status || e ?. response ?. status ;
163+ const message = typeof e ?. message === 'string' ? e . message : '' ;
164+
165+ console . error ( 'Add contact error:' , status , message , e ) ;
166+
167+ if ( status === 404 || message . includes ( '404' ) ) {
168+ return 'The contact could not be found in the pod. Please ensure the username is correct and registered with this pod.' ;
169+ }
170+ if ( status === 401 || status === 403 || message . includes ( '401' ) || message . includes ( '403' ) ) {
171+ return 'You are not authorized to add this contact. Please check your permissions.' ;
172+ }
173+ if ( message . toLowerCase ( ) . includes ( 'network' ) ) {
174+ return 'Network error: Unable to reach the pod. Please check your connection and try again.' ;
175+ }
176+
177+ return 'An unexpected error occurred while adding the contact. Please try again or contact support.' ;
178+ } ;
179+
161180 const handleAddContact = async ( event ) => {
162181 event . preventDefault ( ) ;
163182 setProcessing ( true ) ;
@@ -207,8 +226,8 @@ const AddContactModal = ({
207226 setShowAddContactModal ( false ) ;
208227 clearInputFields ( ) ;
209228 } catch ( e ) {
210- const errorMessage = e ? e . message : 'Unknown error occurred' ;
211- addNotification ( 'error' , `Add contact failed. Reason: ${ errorMessage } ` ) ;
229+ const errorMessage = getUserFriendlyError ( e ) ;
230+ addNotification ( 'error' , `${ errorMessage } ` ) ;
212231 setInvalidWebId ( true ) ;
213232 } finally {
214233 setProcessing ( false ) ;
You can’t perform that action at this time.
0 commit comments