Skip to content

Commit

Permalink
Merge pull request #238 from 9rnsr/improve_unformat
Browse files Browse the repository at this point in the history
Improve error message
  • Loading branch information
jmdavis committed Sep 5, 2011
2 parents 1843f44 + 8e41c85 commit 528a690
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions std/conv.d
Expand Up @@ -2765,26 +2765,34 @@ Target parse(Target, Source)(ref Source s, dchar lbracket = '[', dchar rbracket
if (s.front == rbracket)
{
if (result.length != 0)
parseError("Need more input");
goto Lmanyerr;
s.popFront();
return result;
}
for (size_t i = 0; ; s.popFront(), skipWS(s))
{
if (i == result.length)
parseError("Too many input");
goto Lmanyerr;
result[i++] = parseElement!(ElementType!Target)(s);
skipWS(s);
if (s.front != comma)
{
if (i != result.length)
parseError("Need more input");
goto Lfewerr;
break;
}
}
parseCheck!s(rbracket);

return result;

Lmanyerr:
parseError(text("Too many elements in input, ", result.length, " elements expected."));
assert(0);

Lfewerr:
parseError(text("Too few elements in input, ", result.length, " elements expected."));
assert(0);
}

unittest
Expand Down

0 comments on commit 528a690

Please sign in to comment.