Skip to content

Commit

Permalink
Merge pull request #1363 from DuendeSoftware/joe/unhandled-exception-…
Browse files Browse the repository at this point in the history
…event

Remove raw exception from unhandled exception event
  • Loading branch information
brockallen committed Jul 17, 2023
2 parents 99b3748 + df67a5e commit d93b61d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/IdentityServer/Events/UnhandledExceptionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public UnhandledExceptionEvent(Exception ex)
EventIds.UnhandledException,
ex.Message)
{
Exception = ex;
Details = ex.ToString();
}

Expand All @@ -34,12 +33,4 @@ public UnhandledExceptionEvent(Exception ex)
/// The details.
/// </value>
public string Details { get; set; }

/// <summary>
/// Gets or sets the exception.
/// </summary>
/// <value>
/// The exception.
/// </value>
public Exception Exception { get; set; }
}
45 changes: 45 additions & 0 deletions test/IdentityServer.UnitTests/Events/EventTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) Duende Software. All rights reserved.
// See LICENSE in the project root for license information.


using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Duende.IdentityServer.Configuration;
using Duende.IdentityServer.Endpoints.Results;
using Duende.IdentityServer.Models;
using Duende.IdentityServer.ResponseHandling;
using Duende.IdentityServer.Validation;
using FluentAssertions;
using IdentityModel;
using UnitTests.Common;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.WebUtilities;
using Xunit;
using Duende.IdentityServer.Services;
using Duende.IdentityServer;
using Duende.IdentityServer.Events;

namespace UnitTests.Endpoints.Results;

public class EventTests
{

[Fact]
public void UnhandledExceptionEventCanCallToString()
{
try
{
throw new InvalidOperationException("Boom");
}
catch (Exception ex)
{
var unhandledExceptionEvent = new UnhandledExceptionEvent(ex);

var s = unhandledExceptionEvent.ToString();

s.Should().NotBeNullOrEmpty();
}
}
}

0 comments on commit d93b61d

Please sign in to comment.