/*
* ErrorHandler.cs - Error handler for Level9.Net. Displays error messages and
* appends error information to the applicationlog file.
*
* Copyright (C) 2004 - 2011 Andreas Scherrer
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
*/
using System;
using System.Windows.Forms;
namespace Level9
{
///
/// Error handler for Level9.Net. Displays error messages and appends error
/// information to the application log file.
///
public class ErrorHandler
{
// -- Methods --------------------------------------------------------
///
/// Displays an error message and appends a log message to the
/// application logfile.
///
/// the object type that raises the error
/// a log message
/// an Exception, or null if none occurred
public static void Handle(Type type, string message, Exception e)
{
MessageBox.Show(message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
Logger.Log(type, message, e);
}
///
/// Displays an error message and appends a log message to the
/// application logfile.
///
/// the object that raises the error
/// a log message
/// an Exception, or null if none occurred
public static void Handle(Object obj, string message, Exception e)
{
Handle(obj.GetType(), message, e);
}
///
/// Displays an error message and appends a log message to the
/// application logfile.
///
/// the object type that raises the error
/// a log message
public static void Handle(Type type, string message)
{
Handle(type, message, null);
}
///
/// Displays an error message and appends a log message to the
/// application logfile.
///
/// the object that raises the error
/// a log message
public static void Handle(Object obj, string message)
{
Handle(obj, message, null);
}
}
}