Skip to content

Instantly share code, notes, and snippets.

@birksy89
Last active December 2, 2017 14:42
Show Gist options
  • Save birksy89/60c594032bb69b99213f1ce431d3392c to your computer and use it in GitHub Desktop.
Save birksy89/60c594032bb69b99213f1ce431d3392c to your computer and use it in GitHub Desktop.
How to Log an Exception In Dotnetnuke (DNN)
using Andrew.Modules.xxx.Models;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Services.Exceptions;
using System;
using System.IO;
using System.Net;
namespace Andrew.Modules.xxx.Components
{
public class myClassName : PortalModuleBase
//Must Inherit PortalModuleBase to use "this" in exception
{
public void myMethod()
{
try
{
//Do some stuff
}
catch (Exception ex)
{
//Create Proper Exception
Exceptions.ProcessModuleLoadException(this, ex,true);
//Create Human Readable Alert - Highlighting Who Failed
var objEventLog = new EventLogController();
string logTitle = "Error!";
string logMsg = $"Couldn't proccess {email}";
objEventLog.AddLog(logTitle, logMsg, EventLogController.EventLogType.HOST_ALERT);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment