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

Podcast Player: Show error from API #17537

Merged
merged 2 commits into from Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions extensions/blocks/podcast-player/api.js
Expand Up @@ -30,9 +30,14 @@ export const fetchPodcastFeed = async url => {
}

// Try if we have another block that can embed this URL.
const externalEmbed = await apiFetch( {
path: addQueryArgs( '/oembed/1.0/proxy', { url } ),
} );
let externalEmbed;
try {
externalEmbed = await apiFetch( {
path: addQueryArgs( '/oembed/1.0/proxy', { url } ),
} );
} catch ( err ) {
// We don't care about this error.
}

// We can use an embed block for this URL, unless API returned the fallback code.
const oEmbedLinkCheck = '<a href="' + url + '">' + url + '</a>';
Expand Down
5 changes: 4 additions & 1 deletion extensions/blocks/podcast-player/edit.js
Expand Up @@ -124,7 +124,10 @@ const PodcastPlayerEdit = ( {
// Show error and allow to edit URL.
debug( 'feed error', error );
createErrorNotice(
__( "Your podcast couldn't be embedded. Please double check your URL.", 'jetpack' )
// Error messages already come localized.
error.message ||
// Fallback to a generic message.
__( "Your podcast couldn't be embedded. Please double check your URL.", 'jetpack' )
cpapazoglou marked this conversation as resolved.
Show resolved Hide resolved
);
setIsEditing( true );
}
Expand Down