Skip to content
Snippets Groups Projects
Commit 2bd18505 authored by Philip's avatar Philip
Browse files

Fehlermanagement

parent b4735122
No related branches found
No related tags found
No related merge requests found
...@@ -137,6 +137,7 @@ public class CoAPRessources { ...@@ -137,6 +137,7 @@ public class CoAPRessources {
CBORFactory f = new CBORFactory(); CBORFactory f = new CBORFactory();
String source_address = exchange.getSourceAddress().getHostAddress(); String source_address = exchange.getSourceAddress().getHostAddress();
System.out.println("Received PUT on /data from "+source_address); System.out.println("Received PUT on /data from "+source_address);
boolean errorOccurred = false;
List<String> values = new ArrayList<String>(); List<String> values = new ArrayList<String>();
if (database.doesClientAddressExist(source_address)){ if (database.doesClientAddressExist(source_address)){
...@@ -165,19 +166,24 @@ public class CoAPRessources { ...@@ -165,19 +166,24 @@ public class CoAPRessources {
values.add(Float.toString(paraFloat)); values.add(Float.toString(paraFloat));
break; break;
default: default:
// Error errorOccurred = true;
} }
} }
// Unbekannter Typ oder falsche Reihenfolge
// Füge Daten in Datenbank hinzu. Bei Fehler: INTERNAL_SERVER_ERROR if (errorOccurred){
if (database.addData(source_address, values)){ exchange.respond(ResponseCode.BAD_REQUEST);
exchange.respond(ResponseCode.CHANGED);
}else{ }else{
exchange.respond(ResponseCode.INTERNAL_SERVER_ERROR); // Füge Daten in Datenbank hinzu. Bei Fehler: INTERNAL_SERVER_ERROR
if (database.addData(source_address, values)){
exchange.respond(ResponseCode.CHANGED);
}else{
exchange.respond(ResponseCode.INTERNAL_SERVER_ERROR);
}
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
exchange.respond(ResponseCode.INTERNAL_SERVER_ERROR); exchange.respond(ResponseCode.INTERNAL_SERVER_ERROR);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment