Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public override Task<TypeConverterResult> ReadAsync(IInteractionContext context,
_ => Task.FromResult(TypeConverterResult.FromError(InteractionCommandError.ConvertFailed, $"{option.Type} doesn't have a convertible value."))
};
}
catch (InvalidCastException castEx)
catch (Exception ex) when (ex is FormatException or InvalidCastException)
{
return Task.FromResult(TypeConverterResult.FromError(castEx));
return Task.FromResult(TypeConverterResult.FromError(ex));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public override ApplicationCommandOptionType GetDiscordType()
public override Task<TypeConverterResult> ReadAsync(IInteractionContext context, IApplicationCommandInteractionDataOption option, IServiceProvider services)
{
object value;

if (option.Value is Optional<object> optional)
value = optional.IsSpecified ? optional.Value : default(T);
else
Expand All @@ -52,9 +51,9 @@ public override Task<TypeConverterResult> ReadAsync(IInteractionContext context,
var converted = Convert.ChangeType(value, typeof(T));
return Task.FromResult(TypeConverterResult.FromSuccess(converted));
}
catch (InvalidCastException castEx)
catch (Exception ex) when (ex is FormatException or InvalidCastException)
{
return Task.FromResult(TypeConverterResult.FromError(castEx));
return Task.FromResult(TypeConverterResult.FromError(ex));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public override Task<TypeConverterResult> ReadAsync(IInteractionContext context,
var converted = Convert.ChangeType(option, typeof(T));
return Task.FromResult(TypeConverterResult.FromSuccess(converted));
}
catch (InvalidCastException castEx)
catch (Exception ex) when (ex is FormatException or InvalidCastException)
{
return Task.FromResult(TypeConverterResult.FromError(castEx));
return Task.FromResult(TypeConverterResult.FromError(ex));
}
}
}
Expand Down