Skip to content

Instantly share code, notes, and snippets.

@dilijev
Created October 21, 2012 06:25
Show Gist options
  • Save dilijev/3926120 to your computer and use it in GitHub Desktop.
Save dilijev/3926120 to your computer and use it in GitHub Desktop.
DimensionException
class DimensionException : public std::exception {
private:
size_type _rowsA;
size_type _colsA;
size_type _rowsB;
size_type _colsB;
char _what[256];
public:
DimensionException()
: exception() {
}
DimensionException(size_type rowsA, size_type colsA, size_type rowsB,
size_type colsB)
: _rowsA(rowsA),
_colsA(colsA),
_rowsB(rowsB),
_colsB(colsB) {
snprintf(_what, sizeof(_what), "Size of matrices did not match. "
"Found [%d x %d] and [%d x %d]",
_rowsA, _colsA, _rowsB, _colsB);
}
virtual const char* what() const throw () {
return _what;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment