Skip to content

Commit 0d2f269

Browse files
authored
Make error message more descriptive and run informal tests
In the Draggable class, replace the error message in the definition of setEventDetector() and setEventResponder() with a template literal that includes the erroneous user input, so that it's easier for the user to see which part of their code is causing the problem. Also run a few informal tests of the setters for both detectors and responders by adapting and executing the draggable line demo in pull request #9, including tests with and without erroneous input for the type parameter. Test coverage is not complete but is sufficient for the prototype.
1 parent d3af563 commit 0d2f269

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mathemagical-prototype.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ class Draggable {
658658
this.mousePressedPair[0] = detector;
659659
break;
660660
default:
661-
throw new Error('Event type not currently supported. Please check docs and check for typos.');
661+
throw new Error(`Event type ${type} not currently supported. Please check docs and check for typos.`);
662662
}
663663
}
664664
catch (error) {
@@ -685,7 +685,7 @@ class Draggable {
685685
this.mousePressedPair[1] = responder;
686686
break;
687687
default:
688-
throw new Error('Event type not currently supported. Please check docs and check for typos.');
688+
throw new Error(`Event type ${type} not currently supported. Please check docs and check for typos.`);
689689
}
690690
}
691691
catch (error) {

0 commit comments

Comments
 (0)