#ifndef EXCEPTION_H
#define EXCEPTION_H

/*
 * @(#)Exception.h
 *
 * This file is part of webCDwriter - Network CD Writing.
 *
 * Copyright (C) 2002-2004 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDWserver.cpp for details.
 */

#include <stdarg.h>
#include <stdio.h>
#include "String.h"

/**
 * The base class of all exceptions.
 *
 * @version 20040206
 * @author Jörg P. M. Haeger
 */
class Exception {
protected:
	String msg;
	String help;

public:
	Exception(): msg(""), help("") {}

	Exception(const char *format, ...): msg(""), help("") {
		va_list ap;
		va_start(ap, format);
		char str[4 * 1024];
		vsnprintf(str, sizeof str, format, ap);
		va_end(ap);
		msg = str;
	}

	Exception(String &s): msg(s), help("") {
		String::free(&s);
	}

	Exception(String &s, String &help): msg(s), help(help) {
		String::free(&s);
		String::free(&help);
	}

	String &getHelp() {
		return help;
	}

	String &getMessage() {
		return msg;
	}

	String &toString() {
		return msg;
	}
};

#endif
