#include <iostream>
#include <stdexcept>
using namespace std;

void foo();
int isqrt(int n) throw(domain_error);

int main() {
    try {
        foo();
    } catch (domain_error &e) {
        cout << "domain_error caught" << endl;
    } catch (exception& e) {
        cout << "exception caught" << endl;
    } catch (...) {
        cout << "unexpected type caught" << endl;
    }
}

void foo() {
    cout << isqrt(-1) << endl;
}

int isqrt(int n) throw(domain_error) {
    if (n < 0) {
        throw domain_error("negative argument");
    }

    // implementation

    return 0;
}
