Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/48#discussion_r15048468
  
    --- Diff: core/src/main/java/brooklyn/entity/effector/AddSensor.java ---
    @@ -53,10 +52,23 @@ public AddSensor(T sensor) {
         public void apply(EntityLocal entity) {
             ((EntityInternal)entity).getMutableEntityType().addSensor(sensor);
         }
    -    
    -    public static <T> AttributeSensor<T> newSensor(Class<T> type, 
ConfigBag params) {
    +
    +    public static <T> AttributeSensor<T> newSensor(Class<T> type, 
ConfigBag params){
             String name = Preconditions.checkNotNull(params.get(SENSOR_NAME), 
"name must be supplied when defining a sensor");
    -        return Sensors.newSensor(type, name); 
    +        return Sensors.newSensor(type, name);
    +    }
    +
    +    public static <T> AttributeSensor<T> newSensor(ConfigBag params) {
    +        String name = Preconditions.checkNotNull(params.get(SENSOR_NAME), 
"name must be supplied when defining a sensor");
    +        String className = 
Preconditions.checkNotNull(params.get(SENSOR_TYPE), "target class must be 
supplied when defining a sensor");
    +        Class<T> type = null;
    +
    +        try {
    +            type = (Class<T>) Class.forName(className);
    +        } catch (ClassNotFoundException e) {
    +            throw new IllegalArgumentException("Invalid target type");
    --- End diff --
    
    In the exception, can you include more information to help those diagnosing 
problems from log files. e.g. `"Invalid target type for sensor "+name+": 
"+className`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to