Loading...

Handle All Your Plugin Exceptions In One Place, And Then Hide It!

Handle All Your Plugin Exceptions In One Place, And Then Hide It!

In coding, one of the recommended best practices is to avoid creating duplicate code as it leads to maintenance issues. Therefore, it is advisable to let your Plugin Base class logic handle catching and logging exceptions. However, this creates problems when debugging unit tests because if the plugin throws an exception, the debugger will stop execution at the throw statement in the plugin base, and you won't see the actual line of code where the error occurred. Debugger attributes, such as the DebuggerStepThroughAttribute in the System.Diagnostics namespace, can be added to your base plugin class that contains the throw to force Visual Studio to stop debugging at the actual line where the exception occurred rather than at the plugin base exception handler logic. By doing so, you can save time and easily navigate the path to the exception. The base plugin call site is represented by the [External Code] line and can still be found in the actual exception stack trace. Follow this best practice when coding and enjoy happy coding!

Published on:

Learn more
.Net Dust
.Net Dust

NULL

Share post:

Related posts

Unit Testing with FakeXrmEasy

This post is a detailed rundown of unit testing with FakeXrmEasy - a powerful tool used to enhance testing capabilities. Dive into the intrica...

2 years ago

Power Automate Development: Best Practices To Implement

Power Automate can be overwhelming initially, but don't fret, as this tutorial will guide you on the best development practices to adopt on th...

7 months ago

Debugging Code: My Unconventional Approach | AutomateValue

The author of this article shares their approach to writing code - they almost never debug. While their approach may seem unusual to other dev...

7 months ago

Jared Parsons: Designing C# and Testing a Compiler - Episode 287

In this episode, Jared Parsons, the Principal Developer Lead on the C# Compiler Team, discusses the design and testing of a compiler. Having w...

9 months ago

C++ Code Generator: Generate Code Quickly & Accurately

If you're working on a C++ software project, you know how time-consuming writing precise syntax can be. But fear not, as the rise of AI-powere...

1 year ago

How to Run JavaScript in Visual Studio Code: Quick Guide

If you want to run your JavaScript code in Visual Studio Code, this quick guide has got you covered. Visual Studio Code, developed by Microsof...

1 year ago

Plugin Development Best Practices in Dynamics 365/ Dataverse/ Power Apps

Developing plugins in Dynamics 365/Dataverse requires adherence to Best Practices as prescribed by Microsoft. To ensure efficient and effectiv...

1 year ago

Deploying & Debugging C# Web API Custom Connectors from within Visual Studio! 🚀

This video tutorial showcases how to deploy and debug custom connectors for C# web APIs from within Visual Studio. With this informative guide...

1 year ago

Tell Your Code To Debug When You’re Good And Ready!

This post provides a solution to a common issue faced while working on the Early Bound Generator in which attaching the debugger to the proces...

6 years ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy