Skip to content

Commit

Permalink
fix error message for page not found
Browse files Browse the repository at this point in the history
  • Loading branch information
nbelyh committed Apr 6, 2023
1 parent 125ef0f commit b903bba
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/WebPart/TopFrame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,16 @@ export function TopFrame(props: ITopFrameProps) {
const setPage = async (startPage: string) => {
await Visio.run(refSession.current, async ctx => {
console.log(`[DiagramFrame] set page "${startPage}"`);
ctx.document.setActivePage(startPage);
await ctx.sync();
try {
ctx.document.setActivePage(startPage);
await ctx.sync();
} catch (err) {
if (err.code === 'ItemNotFound') {
throw new Error(`Unable to set active page to "${startPage}" because it is not found. Please check you have specified an existing page in the web part settings.`);
} else {
throw err;
}
}
})
}

Expand Down Expand Up @@ -136,8 +144,16 @@ export function TopFrame(props: ITopFrameProps) {
await sleep(750 * (1 + retry*2));

console.log(`[DiagramFrame] initialize page "${startPage}"`);
ctx.document.setActivePage(startPage);
await ctx.sync();
try {
ctx.document.setActivePage(startPage);
await ctx.sync();
} catch (err) {
if (err.code === 'ItemNotFound') {
throw new Error(`Unable to set active page to "${startPage}" because it is not found. Please check you have specified an existing page in the web part settings.`);
} else {
throw err;
}
}
}

});
Expand Down

0 comments on commit b903bba

Please sign in to comment.