File: driver.cc

package info (click to toggle)
bobcat 6.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 13,960 kB
  • sloc: cpp: 18,954; fortran: 5,617; makefile: 2,787; sh: 659; perl: 401; ansic: 26
file content (78 lines) | stat: -rw-r--r-- 1,728 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include <iostream>
#include "../exception"

#include <fstream>
#include <cerrno>

#include <cstring>

using namespace std;
using namespace FBB;


int main(int argc, char **argv)
{
    string hello = "hello world";

    try
    {
        try
        {                               // throw exception in which data of
                                        // various types were inserted
            throw Exception() << hello << ' ' << 12.34 << "...";
        }
        catch(exception const &e)
        {
            cerr << "first: " << e.what() << '\n';
            throw;                      // may be rethrown, which is standard
        }
    }
    catch(exception const &e)
    {
        cout << "second: exception caught: " << e.what() << '\n';
    }

    try
    {                               // throw exception in which data of
                                    // various types were inserted
        throw Exception(5) << "third: exception with errno value set";
    }
    catch(exception const &e)
    {
        cerr << "fourth: " << e.what() << '\n'
             << "Exception == " << errno << '\n';
    }

    try
    {
        ofstream out;
        Exception::open(out, "out");

        Exception::open(out, "");
    }
    catch(exception const &e)
    {
        cout << "fifth: " << e.what() << '\n';
    }

    try
    {
        ofstream out;
        Exception::open(out, "out", ios::in | ios::out);
    }
    catch(exception const &e)
    {
        cout << "sixth: " << e.what() << '\n';
    }

    try
    {
        throw Exception(E2BIG) << "Error: " << FBB::errnodescr;
    }
    catch(exception const &e)
    {
        cout << "eighth: " << e.what() << '\n';
    }

    cout << "end of program\n";
}