mirror of
https://github.com/epasveer/seer.git
synced 2026-08-30 00:50:42 +08:00
Prepare for the v1.17 release cycle.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
int AddPositiveIntegers (int a, int b) {
|
||||
|
||||
if (a < 0 || b < 0) {
|
||||
throw std::invalid_argument("AddPositiveIntegers arguments must be positive");
|
||||
}
|
||||
|
||||
return a + b;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
try {
|
||||
|
||||
std::cout << AddPositiveIntegers(-1, 2); //exception
|
||||
|
||||
} catch (std::invalid_argument& e) {
|
||||
|
||||
std::cerr << e.what() << std::endl;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user