Skip to content

Commit

Permalink
fix: catch the error of failed resource loading
Browse files Browse the repository at this point in the history
  • Loading branch information
inottn committed Jan 4, 2024
1 parent bfb6b6d commit de892f8
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ export class MiniPoster {
}

async draw(data: ElementConfig | ElementConfig[]) {
if (Array.isArray(data)) {
for (const item of data) {
await this.draw(item);
try {
if (Array.isArray(data)) {
for (const item of data) {
await this.draw(item);
}
} else {
if (data.type === 'container')
await this.renderContainer(normalizeConfig(data));
if (data.type === 'image')
await this.renderImage(normalizeConfig(data));
if (data.type === 'text') await this.renderText(normalizeConfig(data));
}
} else {
if (data.type === 'container')
await this.renderContainer(normalizeConfig(data));
if (data.type === 'image') await this.renderImage(normalizeConfig(data));
if (data.type === 'text') await this.renderText(normalizeConfig(data));
} catch (error) {
// failed to load resources
}
}

Expand Down

0 comments on commit de892f8

Please sign in to comment.