mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-27 00:06:16 +02:00
examples of invalid errors
This commit is contained in:
parent
5b3aefff85
commit
a72b6b2ec8
1 changed files with 24 additions and 1 deletions
|
@ -16,8 +16,10 @@ int main()
|
|||
// In each program where errors occur, this has to be set.
|
||||
ErrorInfo::programName = optional("error-test");
|
||||
|
||||
// There are currently four error types -
|
||||
// There are currently four error types:
|
||||
//
|
||||
// ProgramError, ProgramWarning, NixLangError, NixLangWarning.
|
||||
//
|
||||
// Each error type is created with a specific sequence of builder functions.
|
||||
// Unlike with a constructor, each parameter is clearly named.
|
||||
// If the sequence of function calls isn't followed, then there's a type error.
|
||||
|
@ -41,6 +43,27 @@ int main()
|
|||
.hint(hintfmt("there was a %1%") % "warning") // 'warning' will be yellow.
|
||||
);
|
||||
|
||||
/*
|
||||
// some invalid errors:
|
||||
|
||||
// type error: no hint function.
|
||||
ProgramError()
|
||||
.name("name")
|
||||
.description("error description");
|
||||
|
||||
// type error: description before name.
|
||||
ProgramError()
|
||||
.description("error description")
|
||||
.name("name")
|
||||
.nohint();
|
||||
|
||||
// type error: hint function with regular boost format, not special hintfmt.
|
||||
ProgramError()
|
||||
.description("error description")
|
||||
.name("name")
|
||||
.hint(format("there was a %1%") % "warning");
|
||||
*/
|
||||
|
||||
// NixLangWarning adds nix file, line number, column range, and the lines of code
|
||||
// where a warning occurred.
|
||||
printErrorInfo(
|
||||
|
|
Loading…
Reference in a new issue