I assume that the sketch throws an exception when attempting to access the webserver when it is unavailable.
Java prvides the try-catch construct which will catch an exception and allow the user to decide what to do with it.
Very basic example of using this construct e.g.
Java prvides the try-catch construct which will catch an exception and allow the user to decide what to do with it.
Very basic example of using this construct e.g.
- void setup() {
- try {
- // code that might throw an exception
- int x = 7/0; // division by zero is not permitted
- }
- catch(Exception e) {
- // an exception was thrown so decide what to do with it
- String className = e.getClass().getSimpleName();
- println("Name of exception class: " + className);
- println("Division by zero is not permitted");
- }
- }