Skip to content

Commit 8fa63cf

Browse files
committed
All exceptions thrown from product code should inherit from std::exception
1 parent c426de4 commit 8fa63cf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Release/include/cpprest/details/SafeInt3.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,9 +664,17 @@ namespace safeint3
664664
#define SAFEINT_WEAK
665665
#endif
666666

667-
class SAFEINT_VISIBLE SafeIntException
667+
class SAFEINT_VISIBLE SafeIntException : public std::exception
668668
{
669669
public:
670+
virtual const char* what() const {
671+
if (m_code == SafeIntDivideByZero)
672+
return "SafeIntException(SafeIntDivideByZero)";
673+
if (m_code == SafeIntArithmeticOverflow)
674+
return "SafeIntException(SafeIntArithmeticOverflow)";
675+
return "SafeIntException(?)";
676+
}
677+
670678
SafeIntException() SAFEINT_NOTHROW { m_code = SafeIntNoError; }
671679
SafeIntException( SafeIntError code ) SAFEINT_NOTHROW
672680
{

0 commit comments

Comments
 (0)