Skip to content

Commit

Permalink
logger exception message instead of stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
vazois committed Mar 12, 2025
1 parent 8fb0dca commit cef3bdc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs/common/Format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static async Task<EndPoint[]> TryCreateEndpoint(string singleAddressOrHos
}
catch (Exception ex)
{
logger?.LogError(ex, "Error while trying to resolve hostname:{hostname}", singleAddressOrHostname);
logger?.LogError("Error while trying to resolve hostname: {exMessage} [{hostname}]", ex.Message, singleAddressOrHostname);
}

return null;
Expand Down
3 changes: 1 addition & 2 deletions libs/host/Configuration/OptionsValidators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,7 @@ protected override ValidationResult IsValid(object value, ValidationContext vali
return initValidationResult;

var logger = ((Options)validationContext.ObjectInstance).runtimeLogger;

if (!Format.TryParseAddressList(ipAddresses, 0, out var endpoints, out var errorHostnameOrAddress, useForBind: false, logger: logger))
if (!Format.TryParseAddressList(ipAddresses, 0, out _, out var errorHostnameOrAddress, useForBind: false, logger: logger))
{
var baseError = validationContext.MemberName != null ? base.FormatErrorMessage(validationContext.MemberName) : string.Empty;
var errorMessage = $"{baseError} Expected string in IPv4 / IPv6 format (e.g. 127.0.0.1 / 0:0:0:0:0:0:0:1) or 'localhost' or valid hostname. Actual value: {errorHostnameOrAddress}";
Expand Down

0 comments on commit cef3bdc

Please sign in to comment.