Skip to content

Commit

Permalink
Merge pull request #22 from newfold-labs/enhance/error-handling
Browse files Browse the repository at this point in the history
Improve Error Handling for `FacebookConnectButton`
  • Loading branch information
ramyakrishnai authored Jun 5, 2024
2 parents c63bbf4 + e362b62 commit 1bc20fa
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
14 changes: 7 additions & 7 deletions includes/RestApi/FacebookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public function get_fb_details()
);
}
if ( is_string( $fb_details ) && preg_match( '/^token not found!$/', $fb_details ) ) {
return new \WP_REST_Response(
array(
'status' => 'error',
'details' => 'You are not authorized'
),
401
);
return new \WP_Error(
'nfd_module_facebook_error',
__( 'Details not found.', 'wp-module-facebook' ),
array(
'status' => 404,
),
);
}
else {
return new \WP_REST_Response(
Expand Down
2 changes: 0 additions & 2 deletions src/components/facebookConnectButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const FacebookConnectButton = ({
if (typeof onFailure === 'function') {
onFailure(err);
}
console.error(err);
});
setFieldValue(res.token);
})
Expand All @@ -63,7 +62,6 @@ const FacebookConnectButton = ({
if (typeof onFailure === 'function') {
onFailure(err);
}
console.error(err);
});

const getProfileData = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const getFacebookUserProfileDetails = () => {
return res?.details;
})
.catch((error) => {
throw { message: 'failed to load the data', errorMsg: error };
throw error;
});
};

Expand Down

0 comments on commit 1bc20fa

Please sign in to comment.