Skip to content

Commit

Permalink
Throw block not found exception on createBlock (#24287)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Welcher authored Jul 30, 2020
1 parent 77b6421 commit 90df863
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/blocks/src/api/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export function createBlock( name, attributes = {}, innerBlocks = [] ) {
// Get the type definition associated with a registered block.
const blockType = getBlockType( name );

if ( undefined === blockType ) {
throw new Error( `Block type '${ name }' is not registered.` );
}

// Ensure attributes contains only values defined by block type, and merge
// default values for missing attributes.
const sanitizedAttributes = reduce(
Expand Down

0 comments on commit 90df863

Please sign in to comment.