Skip to content

Commit

Permalink
Handle exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
psrpinto committed Feb 14, 2024
1 parent 8e858ee commit 72dfca7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wporg-gp-translation-events.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,13 @@ function submit_event_ajax() {
if ( ! $event_id ) {
wp_send_json_error( 'Event could not be created or updated' );
}
update_post_meta( $event_id, '_event_start', convert_to_utc( $event_start, $event_timezone ) );
update_post_meta( $event_id, '_event_end', convert_to_utc( $event_end, $event_timezone ) );
try {
update_post_meta( $event_id, '_event_start', convert_to_utc( $event_start, $event_timezone ) );
update_post_meta( $event_id, '_event_end', convert_to_utc( $event_end, $event_timezone ) );
} catch ( Exception $e ) {
wp_send_json_error( 'Invalid start or end' );
}

update_post_meta( $event_id, '_event_timezone', $event_timezone );

try {
Expand Down

0 comments on commit 72dfca7

Please sign in to comment.