Developer forum

Forum » CMS - Standard features » Remove stacktrace

Remove stacktrace

Anders Ebdrup
Reply

Hi Dynamicweb,

 

How can I remove the stacktrace when we have an error in a module - e.g. say the ecom module. I now get this:

An error occured while attaching module (Dynamicweb.Frontend.Content)

And the stacktrace...

So how can I disable this from security reasons and just log the error?

 

Best regards, Anders


Replies

 
Nicolai Høeg Pedersen
Reply

Oh, there it is :-).

In your custom modules GetContent() method, wrap the contents in a try catch and do what you want to do with the exception. Then Dynamicweb will not see it, and hence not display it.

 
Anders Ebdrup
Reply

Please see your private mail about an issue like this

 
Nicolai Høeg Pedersen
Reply

Ah, standard module.

Easy work around is this: <!--@ If(ParagraphModule<contains>'SqlException exception')-->

Also, I cannot reproduce on newer versions than the one you send me.

Nicolai

 
Nicolai Høeg Pedersen
Reply

Or add a simple notification subscriber:

Imports System

Imports System.Web

Imports Dynamicweb

Imports Dynamicweb.Extensibility

Imports Dynamicweb.Notifications

 

<Extensibility.Subscribe(Global.Dynamicweb.Notifications.Standard.Application.BeginRequest)> _

Public Class ApplicationBeginRequestObserver

Inherits Global.Dynamicweb.Extensibility.NotificationSubscriber

Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Global.Dynamicweb.Extensibility.NotificationArgs)

Try

If args Is Nothing Then

Return

End If

If Not (TypeOf args Is Global.Dynamicweb.Notifications.Standard.Application.BeginRequestArgs) Then

Return

End If

Dim item As Global.Dynamicweb.Notifications.Standard.Application.BeginRequestArgs = DirectCast(args, Global.Dynamicweb.Notifications.Standard.Application.BeginRequestArgs)

Dim app As System.Web.HttpApplication = DirectCast(item.sender, System.Web.HttpApplication)

If Not app.Context Is Nothing AndAlso Not app.Context.Request Is Nothing Then

'make data check...

HttpContext.Current.Response.End()

End If

Catch ex As Exception

End Try

End Sub

End Class

 

You must be logged in to post in the forum