How to add value to the default exception response in ABP?


I want to add an ID (GUID) to the exception and:

<ol><li>Log it</li> <li>Return it to the client json response</li> </ol>

Where should I generate this log ID value and add it to the exception message that is logged. And where to change the following default response?

{ "targetUrl": null, "result": null, "success": false, "error": { "message": "An internal error occurred during your request!", "details": "..." }, "unAuthorizedRequest": false }

I am using .NET Core version.


If you want to disable displaying the message for a particular AJAX call, add abpHandleError: false into the abp.ajax options.

Or you can disable the default behavior of the framework exception wrapper

public class PeopleController : AbpController { [HttpPost] [WrapResult(WrapOnSuccess = false, WrapOnError = false)] public JsonResult SavePerson(SavePersonModel person) { //TODO: save new person to database and return new person's id return Json(new {PersonId = 42}); } }

<a href="https://aspnetboilerplate.com/Pages/Documents/Javascript-API/AJAX?searchKey=wrap#asp-net-mvc-controllers" rel="nofollow">https://aspnetboilerplate.com/Pages/Documents/Javascript-API/AJAX?searchKey=wrap#asp-net-mvc-controllers</a>

<hr />

Another thing is; you can send exception details to the client by the below configuration

... using Abp.Web.Configuration; ... public override void PreInitialize() { Configuration.Modules.AbpWebCommon().SendAllExceptionsToClients = true; } ...

<a href="https://aspnetboilerplate.com/Pages/Startup-Configuration#configuring-modules" rel="nofollow">https://aspnetboilerplate.com/Pages/Startup-Configuration#configuring-modules</a>

<hr />

Result Wrapping & Exception Handling:

ASP.NET Boilerplate does not wrap Web API actions by default if an action has successfully executed. It, however, handles and wraps exceptions. You can add the WrapResult/DontWrapResult attributes to actions and controllers for finer control. You can change this default behavior from the startup configuration (using Configuration.Modules.AbpWebApi()...). See the AJAX document for more info about result wrapping.

<a href="https://aspnetboilerplate.com/Pages/Documents/Web-API-Controllers?searchKey=wrap#result-wrapping-exception-handling" rel="nofollow">https://aspnetboilerplate.com/Pages/Documents/Web-API-Controllers?searchKey=wrap#result-wrapping-exception-handling</a>

<hr />

Wrapping Results

ASP.NET Boilerplate wraps the return values of dynamic Web API actions using an AjaxResponse object. See the ajax documentation for more information on wrapping. You can enable/disable wrapping per method or per application service. See this example application service:

public interface ITestAppService : IApplicationService { [DontWrapResult] DoItOutput DoIt(DoItInput input); }

<a href="https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API?searchKey=wrap#wrapping-results" rel="nofollow">https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API?searchKey=wrap#wrapping-results</a>

<hr />

Lastly you can write your own ResultWrapperHandler...

<pre class="lang-cs prettyprint-override">public class CustomResultWrapperHandler : ResultWrapperHandler, ITransientDependency { //... protected override void WrapResultIfNeeded(HttpRequestMessage request, HttpResponseMessage response) { //... base.WrapResultIfNeeded(request, response); } }


  • In the contoller, how do i obtain data from an http post? [duplicate]
  • Null Pointer Exception: HTTP Entity
  • Android json parse not working
  • Render a treeview using a for-loop
  • Why action not found in my controller?
  • Returning Json from controller, never a success
  • Java making confirming exit
  • How to know which Linq statement produced the SQL on hand during runtime?
  • How do I Dispose a HttpResponseMessage in my Web Api Method?
  • How to get the date of next specified day of week
  • LiveData is abstract android
  • drawing random circles, storing their coorindates in an array
  • What's the syntax to inherit documentation from another indexer?
  • Using Generics on right hand side in Java 6?
  • Redirect to Post Method/Action
  • How to return DataSet (xsd) in WCF
  • Cast between interfaces whose interface signatures are same
  • Implementing “partial void” in VB
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • Tamper-proof configuration files in .NET?
  • Display java JPanel in a JFrame
  • How can I set a binding to a Combox in a UserControl?
  • Sort List of Strings By Version
  • Problems compiling files using JOGL
  • Parsing a CSV string while ignoring commas inside the individual columns
  • Swing - Get new component under mouseReleased
  • MVC3 Razor - ListBox pre-select not working
  • Set the selected item in dropdownlist in MVC3
  • ilmerge with a PFX file
  • Spring Data JPA custom method causing PropertyReferenceException
  • Can I display google adwords (AdView) in javafx on android
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • Cannot Parse HTML Data Using Android / JSOUP
  • JTable with a ScrollPane misbehaving
  • unknown Exception android
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?