Kentico custom web part error handling

Tommy De Notarpietro asked on October 28, 2016 10:24

Does Kentico handle unhandled errors in a custom web part ( CMSAbstractWebPart )? In the past I saw a message "Error in webpart..." on the webpart's placeholder, but in a new case the error took down the whole page ( server error ).

In my case I had a System.InvalidOperationException.

Correct Answer

Brenden Kehren answered on October 28, 2016 17:13

To answer your question, Kentico does not handle the errors. It will log the error to the event log but it's up to you to actually handle the exception. As Laura suggests, wrap your code in a try{}catch{} block if you want to actually handle it.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Laura Frese answered on October 28, 2016 16:41

I like to wrap custom things in a try catch that uses the kentico event log

try{

}
catch(Exception ex){
    EventLogProvider.LogEvent(EventType.ERROR, "API Example", "APIEXAMPLE", eventDescription: ex.Message);
}
2 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.