Skip to content

Commit

Permalink
fixed error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Nov 14, 2022
1 parent 0a99979 commit 42c0732
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Expand Up @@ -12,6 +12,9 @@
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;
Expand All @@ -23,6 +26,8 @@
* 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
Expand Down Expand Up @@ -85,8 +90,9 @@ default Result<Collection<AdditionalAttributeRecord>> saveAdditionalAttributes(

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()));
}

Expand Down
Expand Up @@ -95,7 +95,7 @@ public Result<AdditionalAttributeRecord> saveAdditionalAttribute(

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()) {
Expand Down

0 comments on commit 42c0732

Please sign in to comment.