Skip to content

Commit 54d1725

Browse files
committed
Display error message in case of lists API fail.
1 parent 5daf4f3 commit 54d1725

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

views/setup_page.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,23 @@
131131
<?php
132132
// we *could* support paging, but few users have that many lists (and shouldn't)
133133
$lists = $api->get( 'lists', 100, array( 'fields' => 'lists.id,lists.name,lists.email_type_option' ) );
134+
135+
if ( is_wp_error( $lists ) ) {
136+
?>
137+
<div class="error_msg">
138+
<?php
139+
printf(
140+
/* translators: %s: error message */
141+
esc_html__( 'Uh-oh, we couldn\'t get your lists from Mailchimp! Error: %s', 'mailchimp' ),
142+
esc_html( $lists->get_error_message() )
143+
);
144+
?>
145+
</div>
146+
</div> <!-- Close parent div as well. -->
147+
<?php
148+
return;
149+
}
150+
134151
$lists = $lists['lists'];
135152

136153
if ( count( $lists ) === 0 ) {

0 commit comments

Comments
 (0)