fixed error logging
This commit is contained in:
parent
0a99979e32
commit
42c0732159
2 changed files with 9 additions and 3 deletions
|
@ -12,6 +12,9 @@ import java.util.Collection;
|
|||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.api.EntityType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.EntityKey;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Result;
|
||||
|
@ -23,6 +26,8 @@ import ch.ethz.seb.sebserver.webservice.datalayer.batis.model.AdditionalAttribut
|
|||
* in a separated data-base table. */
|
||||
public interface AdditionalAttributesDAO {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(AdditionalAttributesDAO.class);
|
||||
|
||||
/** Use this to get all additional attribute records for a specific entity.
|
||||
*
|
||||
* @param type the entity type
|
||||
|
@ -85,8 +90,9 @@ public interface AdditionalAttributesDAO {
|
|||
|
||||
return Result.tryCatch(() -> attributes.entrySet()
|
||||
.stream()
|
||||
.map(attr -> saveAdditionalAttribute(type, entityId, attr.getKey(), attr.getValue()))
|
||||
.flatMap(Result::onErrorLogAndSkip)
|
||||
.map(attr -> saveAdditionalAttribute(type, entityId, attr.getKey(), attr.getValue())
|
||||
.onError(error -> log.warn("Failed to save additional attribute: ", error.getMessage())))
|
||||
.flatMap(Result::skipOnError)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ public class AdditionalAttributesDAOImpl implements AdditionalAttributesDAO {
|
|||
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"value cannot be null. Use delete to delete an additional attribute");
|
||||
"value cannot be null. Use delete to delete an additional attribute: " + String.valueOf(name));
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
|
|
Loading…
Reference in a new issue