-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Labels
Description
The Po.et Plugin currently ignores any type of errors that could happen when submitting a work to the Frost API.
wordpress-plugin/PoetArticlePoster/PoetArticlePoster.php
Lines 297 to 320 in 8e101c9
| $consumer = new Consumer( $author, $url, $token, $post ); | |
| //Posting the article to the API | |
| try { | |
| $response = $consumer->consume(); | |
| $decoded_response_body = json_decode( $response['body'] ); | |
| //Adding initial empty meta key for the poet work id | |
| update_post_meta( $post_id, 'poet_work_id', '' ); | |
| //Checking if the returned response body is a valid JSON string | |
| if ( json_last_error() !== JSON_ERROR_SYNTAX | |
| && is_object( $decoded_response_body ) | |
| && property_exists( $decoded_response_body, 'workId' ) ) { | |
| //Creating or updating poet work id meta to the returned work id | |
| update_post_meta( $post_id, 'poet_work_id', $decoded_response_body->workId ); | |
| } | |
| } catch ( Exception $exception ) { | |
| } | |
| } |
The catch block is empty, and the if ( json_last_error() !== JSON_ERROR_SYNTAX ... doesn't have an else.
Any error that might prevent the article from actually being persisted by Frost should be both communicated to the user and preserved in a log.
TBD
Proper UI and UX for these error messages