~dobey/unity-api/add-simple-logger

« back to all changes in this revision

Viewing changes to include/unity/UnityExceptions.h

  • Committer: Tarmac
  • Author(s): Michi Henning
  • Date: 2013-12-17 01:48:32 UTC
  • mfrom: (113.2.6 what-fix)
  • Revision ID: tarmac-20131217014832-76rm9a4d3127zhxv
  Changed unity::Exception to return the same string as to_string(). This means that it is no longer necessary
  to treat unity::Exception differently from std::exception for structured exception handling: catching std::exception
  will catch unity::Exception as well, and call what() produces the correct result. The pointer returned from what()
  remains valid until the next call to what(), or until the exception is destroyed.
  
  Added deep-copy semantics for exceptions.
  
  Removed pimpling of unity::Exception, so there is no longer a class called ExceptionImplBase. Pimpling with
  inheritance and deep-copy just gets too messy and confusing.

Approved by James Henstridge, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
    //! @endcond
45
45
 
46
46
    /**
47
 
    \brief Returns the fully-qualified name of the exception.
48
 
    */
49
 
    virtual char const* what() const noexcept override;
50
 
 
51
 
    /**
52
47
    \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
53
48
    */
54
49
    virtual std::exception_ptr self() const override;
74
69
    //! @endcond
75
70
 
76
71
    /**
77
 
    \brief Returns the fully-qualified name of the exception.
78
 
    */
79
 
    virtual char const* what() const noexcept override;
80
 
 
81
 
    /**
82
72
    \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
83
73
    */
84
74
    virtual std::exception_ptr self() const override;
108
98
    //! @endcond
109
99
 
110
100
    /**
111
 
    \brief Returns the fully-qualified name of the exception.
112
 
    */
113
 
    virtual char const* what() const noexcept override;
114
 
 
115
 
    /**
116
101
    \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
117
102
    */
118
103
    virtual std::exception_ptr self() const override;
119
104
};
120
105
 
121
 
namespace internal
122
 
{
123
 
class FileExceptionImpl;
124
 
}
125
106
 
126
107
/**
127
108
\brief Exception to indicate file I/O errors, such as failure to open or write to a file.
146
127
    //! @endcond
147
128
 
148
129
    /**
149
 
    \brief Returns the fully-qualified name of the exception.
150
 
    */
151
 
    virtual char const* what() const noexcept override;
152
 
 
153
 
    /**
154
130
    \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
155
131
    */
156
132
    virtual std::exception_ptr self() const override;
161
137
    int error() const noexcept;
162
138
 
163
139
private:
164
 
    std::shared_ptr<internal::FileExceptionImpl> p_;
 
140
    int err_;
165
141
};
166
142
 
167
 
namespace internal
168
 
{
169
 
class SyscallExceptionImpl;
170
 
}
171
 
 
172
143
/**
173
144
\brief Exception to indicate system or library call errors that set <code>errno</code>.
174
145
*/
192
163
    //! @endcond
193
164
 
194
165
    /**
195
 
    \brief Returns the fully-qualified name of the exception.
196
 
    */
197
 
    virtual char const* what() const noexcept override;
198
 
 
199
 
    /**
200
166
    \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
201
167
    */
202
168
    virtual std::exception_ptr self() const override;
207
173
    int error() const noexcept;
208
174
 
209
175
private:
210
 
    //std::shared_ptr<internal::SyscallExceptionImpl> p_;
 
176
    int err_;
211
177
};
212
178
 
213
179
/**
229
195
    //! @endcond
230
196
 
231
197
    /**
232
 
    \brief Returns the fully-qualified name of the exception.
233
 
    */
234
 
    virtual char const* what() const noexcept override;
235
 
 
236
 
    /**
237
198
    \brief Returns a <code>std::exception_ptr</code> to <code>this</code>.
238
199
    */
239
200
    virtual std::exception_ptr self() const override;