Error Handling

- Improved some task validation errors by including data.
- Improved the phrasing of some error to be less pompous.
- Marked validation errors that need to be downgraded to warnings.
This commit is contained in:
Paul Beckingham 2011-08-21 12:35:47 -04:00
parent 1b55a48757
commit 9a126ce717
2 changed files with 8 additions and 4 deletions

View file

@ -1091,6 +1091,7 @@ void Task::validate () const
Date due (get_date ("due")); Date due (get_date ("due"));
// Verify wait < due // Verify wait < due
// TODO Downgrade to warning.
if (has ("wait")) if (has ("wait"))
{ {
Date wait (get_date ("wait")); Date wait (get_date ("wait"));
@ -1100,6 +1101,7 @@ void Task::validate () const
Date entry (get_date ("entry")); Date entry (get_date ("entry"));
// TODO Downgrade to warning.
if (has ("start")) if (has ("start"))
{ {
Date start (get_date ("start")); Date start (get_date ("start"));
@ -1107,6 +1109,7 @@ void Task::validate () const
throw std::string (STRING_TASK_VALID_START); throw std::string (STRING_TASK_VALID_START);
} }
// TODO Downgrade to warning.
if (has ("end")) if (has ("end"))
{ {
Date end (get_date ("end")); Date end (get_date ("end"));
@ -1128,9 +1131,10 @@ void Task::validate () const
{ {
Duration d; Duration d;
if (! d.valid (get ("recur"))) if (! d.valid (get ("recur")))
throw std::string (STRING_TASK_VALID_RECUR); throw std::string (format (STRING_TASK_VALID_RECUR, get ("recur")));
} }
// TODO Remove this restriction.
if (has ("wait") && if (has ("wait") &&
getStatus () == Task::recurring) getStatus () == Task::recurring)
throw std::string (STRING_TASK_VALID_WAIT_RECUR); throw std::string (STRING_TASK_VALID_WAIT_RECUR);

View file

@ -422,9 +422,9 @@
#define STRING_TASK_VALID_WAIT "A 'wait' date must be before a 'due' date." #define STRING_TASK_VALID_WAIT "A 'wait' date must be before a 'due' date."
#define STRING_TASK_VALID_START "A 'start' date must be after an 'entry' date." #define STRING_TASK_VALID_START "A 'start' date must be after an 'entry' date."
#define STRING_TASK_VALID_END "An 'end' date must be after an 'entry' date." #define STRING_TASK_VALID_END "An 'end' date must be after an 'entry' date."
#define STRING_TASK_VALID_REC_DUE "You cannot specify a recurring task without a due date." #define STRING_TASK_VALID_REC_DUE "A recurring task must also have a 'due' date."
#define STRING_TASK_VALID_UNTIL "You cannot specify an until date for a non-recurring task." #define STRING_TASK_VALID_UNTIL "Only recurring tasks may have an 'until' date."
#define STRING_TASK_VALID_RECUR "A recurrence value must be valid." #define STRING_TASK_VALID_RECUR "The recurrence value '{1}' is not valid."
#define STRING_TASK_VALID_WAIT_RECUR "You cannot create a task that is both waiting and recurring." #define STRING_TASK_VALID_WAIT_RECUR "You cannot create a task that is both waiting and recurring."
#define STRING_TASK_VALID_PRIORITY "Priority values may be 'H', 'M' or 'L', not '{1}'." #define STRING_TASK_VALID_PRIORITY "Priority values may be 'H', 'M' or 'L', not '{1}'."