Skip to content

Commit

Permalink
Remove hardcoded function names in error messages (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
RichDom2185 authored Sep 10, 2023
1 parent 275da7c commit a7deb51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/bundles/sound/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ export function play_wave(wave: Wave, duration: number): AudioPlayed {
export function play(sound: Sound): AudioPlayed {
// Type-check sound
if (!is_sound(sound)) {
throw new Error(`play is expecting sound, but encountered ${sound}`);
throw new Error(`${play.name} is expecting sound, but encountered ${sound}`);
// If a sound is already playing, terminate execution.
} else if (isPlaying) {
throw new Error('play: audio system still playing previous sound');
throw new Error(`${play.name}: audio system still playing previous sound`);
} else if (get_duration(sound) < 0) {
throw new Error('play: duration of sound is negative');
throw new Error(`${play.name}: duration of sound is negative`);
} else {
// Instantiate audio context if it has not been instantiated.
if (!audioplayer) {
Expand Down Expand Up @@ -424,7 +424,7 @@ export function play_concurrently(sound: Sound): void {
// Type-check sound
if (!is_sound(sound)) {
throw new Error(
`play_concurrently is expecting sound, but encountered ${sound}`,
`${play_concurrently.name} is expecting sound, but encountered ${sound}`,
);
} else if (get_duration(sound) <= 0) {
// Do nothing
Expand Down
8 changes: 4 additions & 4 deletions src/bundles/stereo_sound/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@ export function play_waves(
export function play(sound: Sound): AudioPlayed {
// Type-check sound
if (!is_sound(sound)) {
throw new Error(`play is expecting sound, but encountered ${sound}`);
throw new Error(`${play.name} is expecting sound, but encountered ${sound}`);
// If a sound is already playing, terminate execution.
} else if (isPlaying) {
throw new Error('play: audio system still playing previous sound');
throw new Error(`${play.name}: audio system still playing previous sound`);
} else if (get_duration(sound) < 0) {
throw new Error('play: duration of sound is negative');
throw new Error(`${play.name}: duration of sound is negative`);
} else {
// Instantiate audio context if it has not been instantiated.
if (!audioplayer) {
Expand Down Expand Up @@ -484,7 +484,7 @@ export function play_concurrently(sound: Sound): void {
// Type-check sound
if (!is_sound(sound)) {
throw new Error(
`play_concurrently is expecting sound, but encountered ${sound}`,
`${play_concurrently.name} is expecting sound, but encountered ${sound}`,
);
} else if (get_duration(sound) <= 0) {
// Do nothing
Expand Down

0 comments on commit a7deb51

Please sign in to comment.