A shortcut function to build error messages.
This commit is contained in:
parent
6403b2da63
commit
93a99ad7ca
|
@ -188,29 +188,6 @@ final class Scanner
|
||||||
reader_ = null;
|
reader_ = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If error_ is true, throws a ScannerException constructed from errorData_ and
|
|
||||||
/// sets error_ to false.
|
|
||||||
void throwIfError() @safe pure
|
|
||||||
{
|
|
||||||
if(!error_) { return; }
|
|
||||||
error_ = false;
|
|
||||||
throw new ScannerException(errorData_);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Called by internal nothrow/@nogc methods to set an error to be thrown by
|
|
||||||
/// their callers.
|
|
||||||
///
|
|
||||||
/// See_Also: dyaml.exception.MarkedYamlException
|
|
||||||
void setError(string context, const Mark contextMark, string problem,
|
|
||||||
const Mark problemMark) @safe pure nothrow @nogc
|
|
||||||
{
|
|
||||||
assert(error_ == false,
|
|
||||||
"Setting an error when there already is a not yet thrown error");
|
|
||||||
error_ = true;
|
|
||||||
errorData_ =
|
|
||||||
MarkedYAMLExceptionData(context, contextMark, problem, problemMark);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the next token is one of specified types.
|
* Check if the next token is one of specified types.
|
||||||
*
|
*
|
||||||
|
@ -270,6 +247,34 @@ final class Scanner
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// Build an error message in msgBuffer_ and return it as a string.
|
||||||
|
string buildMsg(S ...)(S args) @trusted pure nothrow @nogc
|
||||||
|
{
|
||||||
|
return cast(string)msgBuffer_.printNoGC(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// If error_ is true, throws a ScannerException constructed from errorData_ and
|
||||||
|
/// sets error_ to false.
|
||||||
|
void throwIfError() @safe pure
|
||||||
|
{
|
||||||
|
if(!error_) { return; }
|
||||||
|
error_ = false;
|
||||||
|
throw new ScannerException(errorData_);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by internal nothrow/@nogc methods to set an error to be thrown by
|
||||||
|
/// their callers.
|
||||||
|
///
|
||||||
|
/// See_Also: dyaml.exception.MarkedYamlException
|
||||||
|
void setError(string context, const Mark contextMark, string problem,
|
||||||
|
const Mark problemMark) @safe pure nothrow @nogc
|
||||||
|
{
|
||||||
|
assert(error_ == false,
|
||||||
|
"Setting an error when there already is a not yet thrown error");
|
||||||
|
error_ = true;
|
||||||
|
errorData_ = MarkedYAMLExceptionData(context, contextMark, problem, problemMark);
|
||||||
|
}
|
||||||
|
|
||||||
///Determine whether or not we need to fetch more tokens before peeking/getting a token.
|
///Determine whether or not we need to fetch more tokens before peeking/getting a token.
|
||||||
bool needMoreTokens() @safe pure
|
bool needMoreTokens() @safe pure
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue