Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions msu/utils/type_checkers.nut
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
::MSU.requireTypeArray("integer", vargv);
}

::MSU.requireUInt <- function( ... )
{
foreach (value in vargv)
{
if (typeof value != "integer" || value < 0)
{
::logError(value + " must have the type: unsigned");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue unsigned isn't actually a type and therefore the error should be something more like.

value + " must have the type: integer, and be greater than or equal to 0"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that same vein what about the function name? Should it be something like requireUInt?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe that's better too

throw ::MSU.Exception.InvalidType(value);
}
}
}

::MSU.requireArray <- function( ... )
{
::MSU.requireTypeArray("array", vargv);
Expand Down