More verbose errors

pull/1415/merge
tobspr 2 years ago
parent 3717fe16c1
commit 574a9d9d25

@ -91,14 +91,17 @@ export class AtlasSprite extends BaseSprite {
const link = this.linksByResolution[ORIGINAL_SPRITE_SCALE]; const link = this.linksByResolution[ORIGINAL_SPRITE_SCALE];
assert( if (!link) {
link, throw new Error(
"Link not known: " + "draw: Link for " +
ORIGINAL_SPRITE_SCALE + this.spriteName +
" (having " + " not known: " +
Object.keys(this.linksByResolution) + ORIGINAL_SPRITE_SCALE +
")" " (having " +
); Object.keys(this.linksByResolution) +
")"
);
}
const width = w || link.w; const width = w || link.w;
const height = h || link.h; const height = h || link.h;
@ -166,7 +169,15 @@ export class AtlasSprite extends BaseSprite {
const link = this.linksByResolution[scale]; const link = this.linksByResolution[scale];
if (!link) { if (!link) {
assert(false, `Link not known: ${scale} (having ${Object.keys(this.linksByResolution)})`); throw new Error(
"drawCached: Link for " +
this.spriteName +
" at scale " +
scale +
" not known (having " +
Object.keys(this.linksByResolution) +
")"
);
} }
const scaleW = w / link.w; const scaleW = w / link.w;
@ -244,7 +255,15 @@ export class AtlasSprite extends BaseSprite {
const link = this.linksByResolution[scale]; const link = this.linksByResolution[scale];
if (!link) { if (!link) {
assert(false, `Link not known: ${scale} (having ${Object.keys(this.linksByResolution)})`); throw new Error(
"drawCachedWithClipRect: Link for " +
this.spriteName +
" at scale " +
scale +
" not known (having " +
Object.keys(this.linksByResolution) +
")"
);
} }
const scaleW = w / link.w; const scaleW = w / link.w;
@ -298,6 +317,17 @@ export class AtlasSprite extends BaseSprite {
getAsHTML(w, h) { getAsHTML(w, h) {
const link = this.linksByResolution["0.5"]; const link = this.linksByResolution["0.5"];
if (!link) {
throw new Error(
"getAsHTML: Link for " +
this.spriteName +
" at scale 0.5" +
" not known (having " +
Object.keys(this.linksByResolution) +
")"
);
}
// Find out how much we have to scale it so that it fits // Find out how much we have to scale it so that it fits
const scaleX = w / link.w; const scaleX = w / link.w;
const scaleY = h / link.h; const scaleY = h / link.h;

Loading…
Cancel
Save