added specific exception on CollectorStubs

This commit is contained in:
lucio 2020-04-08 15:40:47 +02:00
parent 61a5cf8700
commit 14b618bf41
1 changed files with 5 additions and 3 deletions

View File

@ -48,7 +48,7 @@ public class CollectorStubs implements RegistryStub {
os.write(profile.getBytes());
}
if (connection.getResponseCode()!=200) throw new Exception("error creating resource "+connection.getResponseCode());
if (connection.getResponseCode()!=200) throw new CreateException("error creating resource "+connection.getResponseCode());
}catch (Exception e) {
log.error("error on create",e);
throw new RemoveException(e.getMessage());
@ -71,7 +71,7 @@ public class CollectorStubs implements RegistryStub {
os.write(profile.getBytes());
}
if (connection.getResponseCode()!=200) throw new Exception("error updating resource "+connection.getResponseCode());
if (connection.getResponseCode()!=200) throw new UpdateException("error updating resource "+connection.getResponseCode());
}catch (Exception e) {
log.error("error on update",e);
throw new RemoveException(e.getMessage());
@ -89,7 +89,9 @@ public class CollectorStubs implements RegistryStub {
connection.setDoInput(true);
if (connection.getResponseCode()!=200){
log.info("response code is not 200");
throw new Exception("error removing resource with id "+id);
if (connection.getResponseCode()==404)
throw new ResourceDoesNotExistException("resource with id "+id+" not found");
else throw new RemoveException("error removing resource with id "+id);
}
}catch (Exception e) {
log.error("error on remove",e);