DotNetNuke error reporting requires improvement

I found that DotNetNuke code often doesn’t report exceptions to user, but hides them.This style of error handling is natural for VB developers, who had the favorite comand “on error resume next”.(I hope that DNN developers are from different school).


 In some cases, exception are written it to EventLog table, but it is not always easy to access. E.g. if errors are occured during install and portal is not created yet, View log Web UI obviously is not available.


I’ve posted the suggestion to DNN support.
Below I listed places where I’ve added exception reporting. I am going to add more as far I will find reporting missing, but useful for my debugging.


In Upgrade.InstallDNN


                ‘After Parse the script nodes


              If Len(strExceptions) > 0 Then ‘mnF 12/4/2006


                    HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, “Exceptions were reported to Default Data Provider log file”)


                    strExceptions = “” ‘reset


                End If


  ‘And After installMemberRole


                If Len(strExceptions) > 0 Then ‘mnF 12/4/2006


                    HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, strExceptions)


                    strExceptions = “” ‘reset


                End If


 


In LibraryComponentsPortalPortalController.vb AddPortalInfo


In catch added Trace exception


 


 


In DNNLibraryComponentsProvidersLoggingException LoggingExceptionLogController.vb


  Sub AddLog(ByVal objException As Exception, ByVal LogType As ExceptionLogType)


            Trace.WriteLine(“DotNetNuke.Services.Log.EventLog.ExceptionLogController.AddLog: “ & LogType.ToString() & ” – “ & objException.ToString())


 


In DNNLibraryComponentsUpgradeUpgrade.vb


‘InstallMemberRoleProvider should save to log any exceptions (if any) in the same way as Upgrade.ExecuteScript does


            If Len(strExceptions) > 0 Then ‘mnf 13/4/2006


                FSHelperLib.StreamHelper.SaveStringToFile(strExceptions, strProviderPath & “InstallMemberRoleProvider.log”)


            End If


 


In DNNLibraryComponentsUsersUserController.vb


Function AddUser


                If Status = UserRegistrationStatus.AddUser Then


‘Existing code removed for brevity


                Else ‘mnf 13/4/2006


                    If UserId < 0 Then ‘TODO may be throw exception


                        Trace.WriteLine(“Unable to AddUser “ & objUser.Membership.Username & ” – “ & Status.ToString())


                    End If


                End If


 


 Function DeleteAllUsers


Catch exc As Exception
                Trace.WriteLine(exc.ToString())


InstallInstall.aspx.vb Function InstallApplication


‘After backing up old web.config
                Catch ex As Exception
                    ‘Error backing up old web.config
                    ‘This error is not critical, so can be ignored
                    System.Diagnostics.Trace.WriteLine(“InstallApplication ” & backupFolder & “web_old.config” & ” error ” & ex.ToString()) 
                End Try


DNNLibraryComponentsSecurityRolesRoleController.vb AddUserRole
                Try
                    AspNetSecurity.Roles.AddUserToRole(objUser.Membership.Username, objUserRole.RoleName)
                Finally ‘instead of Catch ex As Exception
                   
‘Reset the Application Name
    
                    
Common.Globals.SetApplicationName(originalAppName)
                End Try


DNNLibraryComponentsTabsTabController.vb Function GetTab


            Try


                Return FillTabInfo(dr)


            Catch exc As Exception


                System.Diagnostics.Trace.WriteLine(“ComponentsTabsTabController.vb GetTab “ & TabId & ” error “ & exc.ToString())


            Finally


                If Not dr Is Nothing Then


                    dr.Close()


                End If


            End Try


            Return Nothing


DNNLibraryComponentsSkinsSkin.vb in Page_Init


                Dim arrModuleControls As ArrayList = objModuleControls.GetModuleControlsByKey(Key, objModule.ModuleDefID)


                If arrModuleControls.Count = 0 Then


                    System.Diagnostics.Trace.WriteLine(“DotNetNuke.UI.Skins.Skin.Page_Init GetModuleControlsByKey returned 0 controls for key “ & Key)


                End If


DNNLibraryControlsDotNetNuke.WebUtilityClientAPI.vb GetClientAPICapsDOM


Try


                    strFileName = System.Web.HttpContext.Current.Server.MapPath(ScriptPath & “/ClientAPICaps.config”)


                Catch ex As Exception


                    System.Diagnostics.Trace.WriteLine(“DotNetNuke.UI.Utilities.ClientAPIs.GetClientAPICapsDOM “ & ex.ToString())


                    ‘ignore error – worried about people with reverse proxies and such…


                End Try


NEW for DNN 4.4.
LibraryProvidersMembershipProvidersAspNetMembershipProviderAspNetMembershipProvider.vb  CreateUser


Catch exc As Exception ‘ an unexpected error occurred

LogException(exc)  ‘ WHY it is COMMENTED?????????

createStatus = UserCreateStatus.UnexpectedError


End Try

NEW for DNN 4.4.
adminSecuritySendPassword.ascx.vb  cmdSendPassword_Click


                            Try


                                objUser.Membership.Password = UserController.GetPassword(objUser, txtAnswer.Text)


                            Catch ex As Exception


‘Actual exception should be logged


                                canSend = False


                                strMessage = Localization.GetString(“PasswordRetrievalError”, Me.LocalResourceFile)


                            End Try


AND


                              Try


                                Mail.SendMail(objUser, MessageType.PasswordReminder, PortalSettings)


                                strMessage = Localization.GetString(“PasswordSent”, Me.LocalResourceFile)


                            Catch ex As Exception


‘Actual exception should be logged


                               

canSend =
False

                            End Try


C:ProjectsFuncSolnDNNLibraryComponentsFrameworkPageBase.vb PageCulture
Try
preferredLocale = HttpContext.Current.Request(“language”)


…code is omitted


Catch
‘Actual exception should be logged

End Try


 
Advertisements