haiku/headers/build/private/storage/Exception.h
Ingo Weinhold 338b8dc301 Merged changes from branch build_system_redesign at revision 14573.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14574 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-10-29 16:27:43 +00:00

116 lines
1.7 KiB
C++

// Exception
#ifndef _EXCEPTION_H
#define _EXCEPTION_H
#include <stdarg.h>
#include <stdio.h>
#include <String.h>
namespace BPrivate {
namespace Storage {
class Exception {
public:
// constructor
Exception()
: fError(B_OK),
fDescription()
{
}
// constructor
Exception(BString description)
: fError(B_OK),
fDescription(description)
{
}
// constructor
Exception(const char* format,...)
: fError(B_OK),
fDescription()
{
va_list args;
va_start(args, format);
SetTo(B_OK, format, args);
va_end(args);
}
// constructor
Exception(status_t error)
: fError(error),
fDescription()
{
}
// constructor
Exception(status_t error, BString description)
: fError(error),
fDescription(description)
{
}
// constructor
Exception(status_t error, const char* format,...)
: fError(error),
fDescription()
{
va_list args;
va_start(args, format);
SetTo(error, format, args);
va_end(args);
}
// copy constructor
Exception(const Exception& exception)
: fError(exception.fError),
fDescription(exception.fDescription)
{
}
// destructor
~Exception()
{
}
// SetTo
void SetTo(status_t error, BString description)
{
fError = error;
fDescription.SetTo(description);
}
// SetTo
void SetTo(status_t error, const char* format, va_list arg)
{
char buffer[2048];
vsprintf(buffer, format, arg);
SetTo(error, BString(buffer));
}
// GetError
status_t Error() const
{
return fError;
}
// GetDescription
const char* Description() const
{
return fDescription.String();
}
private:
status_t fError;
BString fDescription;
};
}; // namespace Storage
}; // namespace BPrivate
#endif // _EXCEPTION_H