Skip to content

Commit 9806164

Browse files
committed
Merge branch 'refs/heads/update/actions-to-fail-with-exceptions' into add/notices-for-important-api-exceptions
2 parents 91d825a + 8b87c15 commit 9806164

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/CommerceIntegration.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public static function handle_create( $attempt = 0 ): array {
128128
* Handles Commerce Integration partner_metadata updates.
129129
*
130130
* @since 1.4.11
131+
* @throws PinterestApiException Pinterest API exception.
131132
* @return void
132133
*/
133134
public static function handle_sync() {
@@ -171,6 +172,7 @@ public static function handle_sync() {
171172
),
172173
'error'
173174
);
175+
throw $e;
174176
}
175177
}
176178

src/FeedRegistration.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ public function init() {
8282
*
8383
* @return bool
8484
*
85-
* @throws Exception PHP Exception.
86-
* @throws PinterestApiException Pinterest API Exception.
85+
* @throws PinterestApiLocaleException Pinterest API does not support the locale.
86+
* @throws PinterestApiException Pinterest API exception.
87+
* @throws Throwable Any other exception.
8788
*/
8889
public function handle_feed_registration(): bool {
8990

@@ -97,26 +98,19 @@ public function handle_feed_registration(): bool {
9798
}
9899

99100
try {
100-
if ( self::register_feed() ) {
101-
return true;
102-
}
103-
throw new Exception( esc_html__( 'Could not register feed.', 'pinterest-for-woocommerce' ) );
101+
return self::register_feed();
104102
} catch ( PinterestApiLocaleException $e ) {
105103
Pinterest_For_Woocommerce()::save_data( 'merchant_locale_not_valid', true );
106104

107105
// translators: %s: Error message.
108-
$error_message = "Could not register feed. Error: {$e->getMessage()}";
106+
$error_message = "Could not register the feed. Error: {$e->getMessage()}";
109107
self::log( $error_message, 'error' );
110-
return false;
108+
throw $e;
111109
} catch ( PinterestApiException $e ) {
112110
throw $e;
113111
} catch ( Throwable $th ) {
114-
if ( method_exists( $th, 'get_pinterest_code' ) && 4163 === $th->get_pinterest_code() ) {
115-
Pinterest_For_Woocommerce()::save_data( 'merchant_connected_diff_platform', true );
116-
}
117-
118112
self::log( $th->getMessage(), 'error' );
119-
return false;
113+
throw $th;
120114
}
121115
}
122116

0 commit comments

Comments
 (0)