Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Frost Errors #2

Open
lautarodragan opened this issue Jan 24, 2018 · 0 comments
Open

Handle Frost Errors #2

lautarodragan opened this issue Jan 24, 2018 · 0 comments

Comments

@lautarodragan
Copy link
Member

lautarodragan commented Jan 24, 2018

The Po.et Plugin currently ignores any type of errors that could happen when submitting a work to the Frost API.

$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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants