Custom Exception Types
By Kurt Guntheroth, February 01, 2005
Exceptions are runtime events with three important properties-events interrupt normal execution, they occur infrequently, and code that responds to events is in high-level logic, far up the function call stack from code that detects events.
February, 2005: Custom Exception Types
Listing 1
#include <stdio.h>
#include <string>
#include <exception>
// encode "where" info into standard exception
void Throw(char const* file, int line)
{ char buf[500];
sprintf(buf,"%s(%d)", file, line);
throw std::logic_error(std::basic_string<char>(buf));
}