Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NewType does not display the derived class that is throwing the error #1239

Open
sscontact opened this issue Aug 13, 2023 · 1 comment
Open

Comments

@sscontact
Copy link

sscontact commented Aug 13, 2023

Hi,

The constructor evaluates if an argument fails to pass the predicate; it does throw the exception but does not include the derived type as it does in the implicit operator. The exception from the constructor is very generic. Can you please add the derived type?

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: value
   at LanguageExt.NewType`4..ctor(A value)
 public NewType(A value)
  {
      PRED val = default(PRED);
      if (!val.True(value))
      {
          throw new ArgumentOutOfRangeException("value");
      }

      if (Prelude.isnull(value))
      {
          throw new ArgumentNullException("value");
      }

      Value = value;
  }

The implicit operator, include typeof(NEWTYPE).Name

 public static explicit operator A(NewType<NEWTYPE, A, PRED, ORD> type)
  {
      if ((object)type != null)
      {
          return type.Value;
      }

      throw new ArgumentException("Can't explictly convert from a null " + typeof(NEWTYPE).Name);
  }
@louthy
Copy link
Owner

louthy commented Aug 14, 2023

Can you please add the derived type?

Yes, you can. Do an MR and I'll review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants