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

Class & property names are missing from error message when setter is used #416

Open
dipterix opened this issue Aug 3, 2024 · 0 comments

Comments

@dipterix
Copy link

dipterix commented Aug 3, 2024

When setter is missing, the error prints out the message @abracadabra must be <integer>, not <double> so users know the cause of error

some_int <- S7::new_class(
  name = "some_int", 
  properties = list(
    abracadabra = S7::new_property(
      class = S7::class_integer
    )
  )
)
some_int(abracadabra = 1.1)
#> Error: <some_int> object properties are invalid:
#> - @abracadabra must be <integer>, not <double>

When setter is made, the error message is not informative

another_int <- S7::new_class(
  name = "another_int", 
  properties = list(
    abracadabra = S7::new_property(
      class = S7::class_integer,
      setter = function(self, value) {
        self@abracadabra <- as.integer(value)
      }
    )
  )
)
another_int(abracadabra = 1.1)
#> Error: `object` must be an <S7_object>, not a <integer>

Created on 2024-08-03 with reprex v2.1.1

@dipterix dipterix changed the title Class & property names are missing from error message when setter is set Class & property names are missing from error message when setter is used Aug 3, 2024
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

1 participant