Do not wrap result errors when returning them (#73)

This PR removes the wrapping of in-house created result errors with
`Result.FromError` (I did not know this was possible until today, lol),
which reduces code verbosity and makes it easier to read, and replaces
`ArgumentNullError` with `ArgumentInvalidError` when retrieving IDs from
a command context, which, in my opinion, is more correct.

---------

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2023-07-28 21:58:55 +05:00 committed by GitHub
parent a6df26af67
commit f47ebe81c5
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 34 additions and 45 deletions

View file

@ -29,6 +29,6 @@ public class LanguageOption : Option<CultureInfo> {
public override Result Set(JsonNode settings, string from) {
return CultureInfoCache.ContainsKey(from.ToLowerInvariant())
? base.Set(settings, from.ToLowerInvariant())
: Result.FromError(new ArgumentInvalidError(nameof(from), Messages.LanguageNotSupported));
: new ArgumentInvalidError(nameof(from), Messages.LanguageNotSupported);
}
}