Skip to content

Commit a7deb51

Browse files
authored
Remove hardcoded function names in error messages (#238)
1 parent 275da7c commit a7deb51

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/bundles/sound/functions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,12 @@ export function play_wave(wave: Wave, duration: number): AudioPlayed {
340340
export function play(sound: Sound): AudioPlayed {
341341
// Type-check sound
342342
if (!is_sound(sound)) {
343-
throw new Error(`play is expecting sound, but encountered ${sound}`);
343+
throw new Error(`${play.name} is expecting sound, but encountered ${sound}`);
344344
// If a sound is already playing, terminate execution.
345345
} else if (isPlaying) {
346-
throw new Error('play: audio system still playing previous sound');
346+
throw new Error(`${play.name}: audio system still playing previous sound`);
347347
} else if (get_duration(sound) < 0) {
348-
throw new Error('play: duration of sound is negative');
348+
throw new Error(`${play.name}: duration of sound is negative`);
349349
} else {
350350
// Instantiate audio context if it has not been instantiated.
351351
if (!audioplayer) {
@@ -424,7 +424,7 @@ export function play_concurrently(sound: Sound): void {
424424
// Type-check sound
425425
if (!is_sound(sound)) {
426426
throw new Error(
427-
`play_concurrently is expecting sound, but encountered ${sound}`,
427+
`${play_concurrently.name} is expecting sound, but encountered ${sound}`,
428428
);
429429
} else if (get_duration(sound) <= 0) {
430430
// Do nothing

src/bundles/stereo_sound/functions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,12 @@ export function play_waves(
375375
export function play(sound: Sound): AudioPlayed {
376376
// Type-check sound
377377
if (!is_sound(sound)) {
378-
throw new Error(`play is expecting sound, but encountered ${sound}`);
378+
throw new Error(`${play.name} is expecting sound, but encountered ${sound}`);
379379
// If a sound is already playing, terminate execution.
380380
} else if (isPlaying) {
381-
throw new Error('play: audio system still playing previous sound');
381+
throw new Error(`${play.name}: audio system still playing previous sound`);
382382
} else if (get_duration(sound) < 0) {
383-
throw new Error('play: duration of sound is negative');
383+
throw new Error(`${play.name}: duration of sound is negative`);
384384
} else {
385385
// Instantiate audio context if it has not been instantiated.
386386
if (!audioplayer) {
@@ -484,7 +484,7 @@ export function play_concurrently(sound: Sound): void {
484484
// Type-check sound
485485
if (!is_sound(sound)) {
486486
throw new Error(
487-
`play_concurrently is expecting sound, but encountered ${sound}`,
487+
`${play_concurrently.name} is expecting sound, but encountered ${sound}`,
488488
);
489489
} else if (get_duration(sound) <= 0) {
490490
// Do nothing

0 commit comments

Comments
 (0)