Skip to content

Commit

Permalink
Merge pull request #1422 from DuendeSoftware/joe/6.3-bugfix/error-eve…
Browse files Browse the repository at this point in the history
…nt-serialization

Joe/6.3 bugfix/error event serialization
  • Loading branch information
brockallen authored Sep 20, 2023
2 parents 1e7db6b + 523723e commit a4dc28e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/IdentityServer/Events/UnhandledExceptionEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


using System;
using System.Text.Json.Serialization;

namespace Duende.IdentityServer.Events;

Expand Down Expand Up @@ -41,5 +42,6 @@ public UnhandledExceptionEvent(Exception ex)
/// <value>
/// The exception.
/// </value>
[JsonIgnore] // Don't try to serialize exceptions, because System.Text.Json will fail (it doesn't support the pointers inside a call stack)
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 a4dc28e

Please sign in to comment.