A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/signumsoftware/framework/commit/0b422b488458677614383875b4fbc0e499093bb7 below:

fixes for ClientErrorModel · signumsoftware/framework@0b422b4 · GitHub

1 1

using System.Threading;

2 2

using System.Collections.Specialized;

3 -

using Microsoft.AspNetCore.Mvc.Filters;

4 -

using Microsoft.AspNetCore.Http.Features;

5 -

using Microsoft.AspNetCore.Http.Extensions;

6 -

using System.Net;

7 -

using Microsoft.AspNetCore.Http;

8 3 9 4

namespace Signum.Entities.Basics;

10 5

@@ -16,43 +11,30 @@ public class ExceptionEntity : Entity

16 11

#pragma warning disable CS8618 // Non-nullable field is uninitialized.

17 12

public ExceptionEntity() { }

18 13 19 -

public ExceptionEntity(ClientExceptionModel clientException, HttpContext httpContext)

14 +

public ExceptionEntity(ClientErrorModel clientError)

20 15

{

21 -

if (httpContext != null)

22 -

{

23 -

var req = httpContext.Request;

24 -

var connFeature = httpContext.Features.Get<IHttpConnectionFeature>()!;

25 - 26 -

this.ExceptionType = clientException.ExceptionType;

27 -

this.ExceptionMessage = clientException.TypeErrorMessage;

28 -

this.StackTrace = new BigStringEmbedded(clientException.TypeErrorStack);

29 -

this.ThreadId = -1;

30 -

this.UserAgent = Try(300, () => req.Headers["User-Agent"].FirstOrDefault());

31 -

this.RequestUrl = Try(int.MaxValue, () => req.GetDisplayUrl());

32 -

this.UrlReferer = Try(int.MaxValue, () => req.Headers["Referer"].ToString());

33 -

this.UserHostAddress = Try(100, () => connFeature.RemoteIpAddress?.ToString());

34 -

this.UserHostName = Try(100, () => connFeature.RemoteIpAddress == null ? null : Dns.GetHostEntry(connFeature.RemoteIpAddress).HostName);

35 - 36 -

this.MachineName = System.Environment.MachineName;

37 -

this.ApplicationName = AppDomain.CurrentDomain.FriendlyName;

38 -

this.IsClientSide = true;

39 - 40 -

this.Form = new BigStringEmbedded();

41 -

this.QueryString = new BigStringEmbedded();

42 -

this.Session = new BigStringEmbedded();

43 -

this.Data = new BigStringEmbedded();

44 -

}

16 +

this.RebindEvents();

17 +

this.ExceptionType = "/".Combine(clientError.ErrorType, clientError.Name);

18 +

this.ExceptionMessage = clientError.Message;

19 +

this.StackTrace = new BigStringEmbedded(clientError.Stack);

20 +

this.ThreadId = -1;

21 + 22 +

this.MachineName = System.Environment.MachineName;

23 +

this.ApplicationName = AppDomain.CurrentDomain.FriendlyName;

24 +

this.Origin = ExceptionOrigin.Frontend_React;

45 25

}

46 26 47 27

public ExceptionEntity(Exception ex)

48 28

{

29 +

this.RebindEvents();

49 30

this.ExceptionType = ex.GetType().Name;

50 31

this.ExceptionMessage = ex.Message!;

51 32

this.StackTrace = new BigStringEmbedded(ex.StackTrace!);

52 33

this.ThreadId = Thread.CurrentThread.ManagedThreadId;

53 34

ex.Data[ExceptionDataKey] = this;

54 35

this.MachineName = System.Environment.MachineName;

55 36

this.ApplicationName = AppDomain.CurrentDomain.FriendlyName;

37 +

this.Origin = ExceptionOrigin.Backend_DotNet;

56 38

}

57 39

#pragma warning restore CS8618 // Non-nullable field is uninitialized.

58 40

@@ -142,7 +124,7 @@ public BigStringEmbedded StackTrace

142 124 143 125

public bool Referenced { get; set; }

144 126 145 -

public bool IsClientSide { get; set; }

127 +

public ExceptionOrigin Origin { get; set; }

146 128 147 129

public override string ToString()

148 130

{

@@ -153,18 +135,12 @@ public static string Dump(NameValueCollection nameValueCollection)

153 135

{

154 136

return nameValueCollection.Cast<string>().ToString(key => key + ": " + nameValueCollection[key], "\r\n");

155 137

}

138 +

}

156 139 157 -

private static string? Try(int size, Func<string?> getValue)

158 -

{

159 -

try

160 -

{

161 -

return getValue()?.TryStart(size);

162 -

}

163 -

catch (Exception e)

164 -

{

165 -

return (e.GetType().Name + ":" + e.Message).TryStart(size);

166 -

}

167 -

}

140 +

public enum ExceptionOrigin

141 +

{

142 +

Backend_DotNet,

143 +

Frontend_React

168 144

}

169 145 170 146

@@ -225,16 +201,16 @@ public class DeleteLogsTypeOverridesEmbedded : EmbeddedEntity

225 201

}

226 202

}

227 203 228 -

public class ClientExceptionModel : ModelEntity

204 +

[AllowUnathenticated]

205 +

public class ClientErrorModel : ModelEntity

229 206

{

230 -

public string TypeErrorMessage { get; set; }

207 +

public string ErrorType { get; set; }

208 + 209 +

public string Message { get; set; }

231 210 232 -

public string? TypeErrorStack { get; set; }

211 +

public string? Stack { get; set; }

233 212 234 -

public string? TypeErrorName { get; set; }

235 - 236 -

public string? ExceptionType { get; set; }

213 +

public string? Name { get; set; }

237 214

}

238 215 239 - 240 216

#pragma warning restore CS8618 // Non-nullable field is uninitialized.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4