Changed way to log and throw up exception
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@117434 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
98db31d173
commit
67f32854d5
|
@ -51,7 +51,7 @@ public class ServiceUsageRecordAggregationStrategy extends AggregationStrategy<S
|
|||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new UnsupportedOperationException(e.getCause());
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
|
||||
return t;
|
||||
|
|
|
@ -33,7 +33,7 @@ public class StorageUsageRecordAggregationStrategy extends AggregationStrategy<S
|
|||
t.setOperationCount(t.getOperationCount() + record.getOperationCount());
|
||||
t.setDataVolume(t.getDataVolume() + record.getDataVolume());
|
||||
}catch(Exception e){
|
||||
throw new UnsupportedOperationException(e.getCause());
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
|
||||
return t;
|
||||
|
|
|
@ -64,7 +64,7 @@ public abstract class AggregationStrategy<T extends AggregatedUsageRecord<T, B>,
|
|||
messageDigest.update(concatenation.getBytes());
|
||||
return new String(messageDigest.digest());
|
||||
}catch(NoSuchAlgorithmException e){
|
||||
throw new UnsupportedOperationException(e.getCause());
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ public abstract class AggregationStrategy<T extends AggregatedUsageRecord<T, B>,
|
|||
convertedRecord = t.getAggregatedUsageRecord(record);
|
||||
return aggregate(convertedRecord);
|
||||
} catch (InvalidValueException e) {
|
||||
throw new NotAggregatableRecordsExceptions(e.getCause());
|
||||
throw new NotAggregatableRecordsExceptions(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ public abstract class JobUsageRecord extends BasicUsageRecord {
|
|||
return wallDuration;
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(String.format("To calculate Wall Duration both %s and %s must be set",
|
||||
START_TIME, END_TIME), e.getCause());
|
||||
START_TIME, END_TIME), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class TestUsageRecord {
|
|||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e.getCause());
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw e;
|
||||
}
|
||||
return usageRecord;
|
||||
|
@ -86,8 +86,8 @@ public class TestUsageRecord {
|
|||
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e.getCause());
|
||||
throw new RuntimeException(e.getCause());
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
|
||||
|
@ -109,8 +109,8 @@ public class TestUsageRecord {
|
|||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e.getCause());
|
||||
throw new RuntimeException(e.getCause());
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
|
||||
|
@ -141,8 +141,8 @@ public class TestUsageRecord {
|
|||
|
||||
|
||||
} catch (InvalidValueException | URISyntaxException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e.getCause());
|
||||
throw new RuntimeException(e.getCause());
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
|
||||
|
@ -157,8 +157,8 @@ public class TestUsageRecord {
|
|||
try {
|
||||
usageRecord.setScope(TEST_SCOPE);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e.getCause());
|
||||
throw new RuntimeException(e.getCause());
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Setting the Scope", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return usageRecord;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class TestUsageRecord {
|
|||
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e.getCause());
|
||||
logger.error(" ------ You SHOULD NOT SEE THIS MESSAGE. Error Creating a test Usage Record", e);
|
||||
}
|
||||
return usageRecord;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class NotEmptyValidator implements FieldAction{
|
|||
return value;
|
||||
}
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ValidDataTypeValidator implements FieldAction {
|
|||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
|
||||
throw new InvalidValueException(ERROR);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class ValidIPValidator implements FieldAction{
|
|||
IPV6_PATTERN = Pattern.compile(ipv6Regex,
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to compile pattern", e.getCause());
|
||||
logger.error("Unable to compile pattern", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class ValidIPValidator implements FieldAction{
|
|||
return (String) value;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class ValidLongValidator implements FieldAction {
|
|||
return longObj;
|
||||
}
|
||||
}catch (Exception e) {
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class ValidOperationResultValidator implements FieldAction {
|
|||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
|
||||
throw new InvalidValueException(ERROR);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ValidOperationTypeValidator implements FieldAction {
|
|||
}
|
||||
|
||||
}catch(Exception e){
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
|
||||
throw new InvalidValueException(ERROR);
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ValidURIValidator implements FieldAction {
|
|||
return new URI((String) value);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
throw new InvalidValueException(ERROR, e.getCause());
|
||||
throw new InvalidValueException(ERROR, e);
|
||||
}
|
||||
throw new InvalidValueException(ERROR);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ResourceAccounting {
|
|||
try {
|
||||
persistence.account(message);
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error("The Record you are going to account is not valid", e.getCause());
|
||||
logger.error("The Record you are going to account is not valid", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,9 +111,9 @@ public abstract class AccountingPersistence {
|
|||
}
|
||||
|
||||
} catch (InvalidValueException e) {
|
||||
logger.error("Error validating UsageRecord", e.getCause());
|
||||
logger.error("Error validating UsageRecord", e);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error accounting UsageRecord", e.getCause());
|
||||
logger.error("Error accounting UsageRecord", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ public abstract class AccountingPersistenceFactory {
|
|||
}
|
||||
} catch(Exception e){
|
||||
logger.error("Unable to instance a Persistence Implementation. Using fallback as default",
|
||||
e.getCause());
|
||||
e);
|
||||
persistence = fallbackPersistence;
|
||||
}
|
||||
persistence.setAggregationScheduler(AggregationScheduler.getInstance());
|
||||
|
|
Loading…
Reference in New Issue