Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function showException(exception) {
addons.getChannel().emit(Events.STORY_THREW_EXCEPTION, exception);
showErrorDisplay(exception);
// Log the stack to the console. So, user could check the source code.
logger.error(exception.stack);
}
private handleEvent(rawEvent: RawEvent): void {
try {
const { data } = rawEvent;
const { key, event } = typeof data === 'string' && isJSON(data) ? parse(data) : data;
if (key === KEY) {
logger.debug(`message arrived at ${this.config.page}`, event.type, ...event.args);
this.handler(event);
}
} catch (error) {
logger.error(error);
// debugger;
}
}
}
const leafId = leafChildren[0];
const component = { ...rest, id: leafId, isLeaf: true, isComponent: true };
componentIdToLeafId[id] = leafId;
if (
(isComponent && nonLeafChildren.length > 0) ||
(!isComponent && nonLeafChildren.length === 0)
) {
throw new Error(
`Unexpected '${item.id}': ${JSON.stringify({ isComponent, nonLeafChildren })}`
);
}
if (nonLeafChildren.length > 0) {
logger.error(
`Node ${item.id} contains non-leaf nodes that are getting removed: ${nonLeafChildren}!`
);
}
return component;
});
setFilter = (filter: string | null) => {
const iframe = getIframe();
if (iframe) {
iframe.style.filter = getFilter(filter);
this.setState({
expanded: false,
filter,
});
} else {
logger.error('Cannot find Storybook iframe');
}
};
if (kindVal && !storyVal) {
return i.kind === kindVal;
}
if (!kindVal && !storyVal) {
return i.kind === current.kind;
}
return false;
});
if (item) {
navigate({
kind: item.kind,
story: item.story,
});
} else {
logger.error('could not navigate to provided story');
}
};
export const setAll = (itemToSet: string | number, changes: any): void => {
try {
const serializedChanges = JSON.stringify(changes);
localStorage.setItem(itemToSet, serializedChanges);
} catch (e) {
logger.error(e);
}
};
fromId = id => {
try {
const data = this._data[id];
if (!data || !data.getDecorated) {
return null;
}
return data;
} catch (e) {
logger.warn('failed to get story:', this._data);
logger.error(e);
return {};
}
};