orsjb / HappyBrackets

HappyBrackets is an audio-focused library and toolkit for creative coding for the internet of things.
Apache License 2.0
36 stars 3 forks source link

General exception handling #57

Open orsjb opened 6 years ago

orsjb commented 6 years ago

Need to ensure that the user always sees Exceptions. We should ensure as best we can that all the threads set up by HB are catching and reporting exceptions. e.g., Currently an exception that occurs in a SensorListener's sensorUpdated() method does not get reported.

angelofraietta commented 6 years ago

Can you please give an example of the code that caused it?

I suspect I can put it in Sensor

   protected void notifyListeners() {
        Iterator var1 = this.listeners.iterator();

        while(var1.hasNext()) {
            SensorUpdateListener listener = (SensorUpdateListener)var1.next();
            listener.sensorUpdated();
        }

    }
angelofraietta commented 6 years ago

in HB we should also deprecate

public Sensor getSensor(Class sensorClass) {

and add one that throws null pinter exception to say we were not able to create

That way we do not need to check for sensor


 Accelerometer sensor = (Accelerometer)hb.getSensor(Accelerometer.class);
        if (sensor != null){ // not needed any more and they will have to add catch by compiler