From d413aadb4a01b7d121eb3de5a4a95733ba3d72aa Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Tue, 29 May 2012 13:46:56 +0100 Subject: [PATCH] tidy up resource not found exception handling. --- .../ReadExtraDataAndReportingServiceImpl.java | 28 +++++-------------- ...atformResourceNotFoundExceptionMapper.java | 10 +++---- ...actPlatformResourceNotFoundException.java} | 4 +-- .../AdditionalFieldsNotFoundException.java | 17 +++++++++++ .../exceptions/ClientNotFoundException.java | 2 +- .../exceptions/CurrencyNotFoundException.java | 2 +- .../exceptions/LoanNotFoundException.java | 2 +- .../LoanProductNotFoundException.java | 2 +- .../LoanTransactionNotFoundException.java | 2 +- .../exceptions/NoteNotFoundException.java | 2 +- .../exceptions/OfficeNotFoundException.java | 2 +- .../exceptions/ReportNotFoundException.java | 11 ++++++++ .../exceptions/RoleNotFoundException.java | 2 +- .../exceptions/UserNotFoundException.java | 2 +- ...WritePlatformServiceJpaRepositoryImpl.java | 22 +++++++-------- 15 files changed, 62 insertions(+), 48 deletions(-) rename mifosng-provider/src/main/java/org/mifosng/platform/exceptions/{PlatformResourceNotFoundException.java => AbstractPlatformResourceNotFoundException.java} (74%) create mode 100644 mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AdditionalFieldsNotFoundException.java create mode 100644 mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java index d33e640e1..48e080d43 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/ReadExtraDataAndReportingServiceImpl.java @@ -20,8 +20,9 @@ import org.mifosng.data.AdditionalFieldsSet; import org.mifosng.data.reports.GenericResultset; import org.mifosng.data.reports.ResultsetColumnHeader; import org.mifosng.data.reports.ResultsetDataRow; +import org.mifosng.platform.exceptions.AdditionalFieldsNotFoundException; import org.mifosng.platform.exceptions.PlatformDataIntegrityException; -import org.mifosng.platform.exceptions.PlatformResourceNotFoundException; +import org.mifosng.platform.exceptions.ReportNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -311,10 +312,7 @@ public class ReadExtraDataAndReportingServiceImpl implements if (rs.next()) { sql = rs.getString("the_sql"); } else { - throw new PlatformResourceNotFoundException( - "error.msg.report.name.not.found", - "Reporting Meta Data Entry Not Found", "Input Sql: " - + inputSql); + throw new ReportNotFoundException(inputSql); } db_statement.close(); @@ -476,18 +474,12 @@ public class ReadExtraDataAndReportingServiceImpl implements } while (rs.next()); result.setData(resultsetDataRows); } else { - throw new PlatformResourceNotFoundException( - "error.msg.type.value.not.found", - "Additional Fields Type: " + type - + " Id Not Found for " + id); + throw new AdditionalFieldsNotFoundException(type, id); } db_statement3.close(); db_statement3 = null; } else { - throw new PlatformResourceNotFoundException( - "error.msg.set.not.found", - "Additional Fields Set Not Found", "Type: " + type - + " Set: " + set); + throw new AdditionalFieldsNotFoundException(type, set); } db_statement1.close(); db_statement1 = null; @@ -576,10 +568,7 @@ public class ReadExtraDataAndReportingServiceImpl implements db_statement = null; db_connection.close(); db_connection = null; - throw new PlatformResourceNotFoundException( - "error.msg.set.not.found", - "Additional Fields Set Not Found", "Type: " + type - + " Set: " + set); + throw new AdditionalFieldsNotFoundException(type, set); } db_statement.close(); db_statement = null; @@ -618,10 +607,7 @@ public class ReadExtraDataAndReportingServiceImpl implements db_statement = null; db_connection.close(); db_connection = null; - throw new PlatformResourceNotFoundException( - "error.msg.type.value.not.found", - "Additional Fields Type: " + type - + " Id Not Found for " + id); + throw new AdditionalFieldsNotFoundException(type, id); } db_statement.close(); db_statement = null; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/errorhandling/PlatformResourceNotFoundExceptionMapper.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/errorhandling/PlatformResourceNotFoundExceptionMapper.java index fd24765ad..8ed1cb71c 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/errorhandling/PlatformResourceNotFoundExceptionMapper.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/errorhandling/PlatformResourceNotFoundExceptionMapper.java @@ -6,22 +6,22 @@ import javax.ws.rs.ext.ExceptionMapper; import javax.ws.rs.ext.Provider; import org.mifosng.data.ApiGlobalErrorResponse; -import org.mifosng.platform.exceptions.PlatformResourceNotFoundException; +import org.mifosng.platform.exceptions.AbstractPlatformResourceNotFoundException; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; /** - * An {@link ExceptionMapper} to map {@link PlatformResourceNotFoundException} thrown by platform into a HTTP API friendly format. + * An {@link ExceptionMapper} to map {@link AbstractPlatformResourceNotFoundException} thrown by platform into a HTTP API friendly format. * - * The {@link PlatformResourceNotFoundException} is thrown when an api call for a resource that is expected to exist does not. + * The {@link AbstractPlatformResourceNotFoundException} is thrown when an api call for a resource that is expected to exist does not. */ @Provider @Component @Scope("singleton") -public class PlatformResourceNotFoundExceptionMapper implements ExceptionMapper { +public class PlatformResourceNotFoundExceptionMapper implements ExceptionMapper { @Override - public Response toResponse(PlatformResourceNotFoundException exception) { + public Response toResponse(AbstractPlatformResourceNotFoundException exception) { ApiGlobalErrorResponse notFoundErrorResponse = ApiGlobalErrorResponse.notFound(exception.getGlobalisationMessageCode(), exception.getDefaultUserMessage(), exception.getDefaultUserMessageArgs()); return Response.status(Status.NOT_FOUND).entity(notFoundErrorResponse).build(); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformResourceNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformResourceNotFoundException.java similarity index 74% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformResourceNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformResourceNotFoundException.java index 3b55eb9ab..a6db81bae 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/PlatformResourceNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AbstractPlatformResourceNotFoundException.java @@ -3,13 +3,13 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when resources that are queried for are not found. */ -public class PlatformResourceNotFoundException extends RuntimeException { +public abstract class AbstractPlatformResourceNotFoundException extends RuntimeException { private final String globalisationMessageCode; private final String defaultUserMessage; private final Object[] defaultUserMessageArgs; - public PlatformResourceNotFoundException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) { + public AbstractPlatformResourceNotFoundException(String globalisationMessageCode, String defaultUserMessage, Object... defaultUserMessageArgs) { this.globalisationMessageCode = globalisationMessageCode; this.defaultUserMessage = defaultUserMessage; this.defaultUserMessageArgs = defaultUserMessageArgs; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AdditionalFieldsNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AdditionalFieldsNotFoundException.java new file mode 100644 index 000000000..1a076ce4a --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/AdditionalFieldsNotFoundException.java @@ -0,0 +1,17 @@ +package org.mifosng.platform.exceptions; + +/** + * A {@link RuntimeException} thrown when client resources are not found. + */ +public class AdditionalFieldsNotFoundException extends AbstractPlatformResourceNotFoundException { + + public AdditionalFieldsNotFoundException(final String type, final Long id) { + super("error.msg.type.value.not.found", "Additional Fields Type: " + + type + " Id Not Found for " + id); + } + + public AdditionalFieldsNotFoundException(final String type, final String set) { + super("error.msg.set.not.found", "Additional Fields Set Not Found", + "Type: " + type + " Set: " + set); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java index 4609919ec..5b42f24ec 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ClientNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when client resources are not found. */ -public class ClientNotFoundException extends PlatformResourceNotFoundException { +public class ClientNotFoundException extends AbstractPlatformResourceNotFoundException { public ClientNotFoundException(Long id) { super("error.msg.client.id.invalid", "Client with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java index ad84491f4..189440836 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/CurrencyNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when loan resources are not found. */ -public class CurrencyNotFoundException extends PlatformResourceNotFoundException { +public class CurrencyNotFoundException extends AbstractPlatformResourceNotFoundException { public CurrencyNotFoundException(final String currencyCode) { super("error.msg.currency.currencyCode.invalid", "Currency with identifier " + currencyCode + " does not exist", currencyCode); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java index b440778ff..f650b34db 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when loan resources are not found. */ -public class LoanNotFoundException extends PlatformResourceNotFoundException { +public class LoanNotFoundException extends AbstractPlatformResourceNotFoundException { public LoanNotFoundException(Long id) { super("error.msg.loan.id.invalid", "Loan with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java index dd772a03a..35001c79e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanProductNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when loan product resources are not found. */ -public class LoanProductNotFoundException extends PlatformResourceNotFoundException { +public class LoanProductNotFoundException extends AbstractPlatformResourceNotFoundException { public LoanProductNotFoundException(Long id) { super("error.msg.loanproduct.id.invalid", "Loan product with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java index ae168eea3..b5c7b3adb 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/LoanTransactionNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when loan resources are not found. */ -public class LoanTransactionNotFoundException extends PlatformResourceNotFoundException { +public class LoanTransactionNotFoundException extends AbstractPlatformResourceNotFoundException { public LoanTransactionNotFoundException(Long id) { super("error.msg.loan.id.invalid", "Loan with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java index a7c750c9d..f83c91ff7 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/NoteNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when note resources are not found. */ -public class NoteNotFoundException extends PlatformResourceNotFoundException { +public class NoteNotFoundException extends AbstractPlatformResourceNotFoundException { public NoteNotFoundException(Long id) { super("error.msg.note.id.invalid", "Note with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java index c681397e1..cb7dad7f5 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/OfficeNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when office resources are not found. */ -public class OfficeNotFoundException extends PlatformResourceNotFoundException { +public class OfficeNotFoundException extends AbstractPlatformResourceNotFoundException { public OfficeNotFoundException(Long id) { super("error.msg.office.id.invalid", "Office with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java new file mode 100644 index 000000000..bb63538c5 --- /dev/null +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/ReportNotFoundException.java @@ -0,0 +1,11 @@ +package org.mifosng.platform.exceptions; + +/** + * A {@link RuntimeException} thrown when report resources are not found. + */ +public class ReportNotFoundException extends AbstractPlatformResourceNotFoundException { + + public ReportNotFoundException(final String reportSql) { + super("error.msg.report.name.not.found", "Reporting Meta Data Entry Not Found", "Input Sql: " + reportSql); + } +} \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java index 00c64d4c7..4600d7d06 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/RoleNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when role resources are not found. */ -public class RoleNotFoundException extends PlatformResourceNotFoundException { +public class RoleNotFoundException extends AbstractPlatformResourceNotFoundException { public RoleNotFoundException(Long id) { super("error.msg.role.id.invalid", "Role with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java index 13aaafb56..d809da215 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/UserNotFoundException.java @@ -3,7 +3,7 @@ package org.mifosng.platform.exceptions; /** * A {@link RuntimeException} thrown when user resources are not found. */ -public class UserNotFoundException extends PlatformResourceNotFoundException { +public class UserNotFoundException extends AbstractPlatformResourceNotFoundException { public UserNotFoundException(Long id) { super("error.msg.user.id.invalid", "User with identifier " + id + " does not exist", id); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 8a9efc5ed..1ce07dd82 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/loan/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -24,9 +24,9 @@ import org.mifosng.platform.client.domain.Note; import org.mifosng.platform.client.domain.NoteRepository; import org.mifosng.platform.currency.domain.MonetaryCurrency; import org.mifosng.platform.currency.domain.Money; +import org.mifosng.platform.exceptions.LoanNotFoundException; import org.mifosng.platform.exceptions.NoAuthorizationException; import org.mifosng.platform.exceptions.PlatformDomainRuleException; -import org.mifosng.platform.exceptions.PlatformResourceNotFoundException; import org.mifosng.platform.loan.domain.AmortizationMethod; import org.mifosng.platform.loan.domain.DefaultLoanLifecycleStateMachine; import org.mifosng.platform.loan.domain.InterestCalculationPeriodMethod; @@ -164,7 +164,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId)); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", loanId); + throw new LoanNotFoundException(loanId); } if (loan.isNotSubmittedAndPendingApproval()) { @@ -192,7 +192,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotApproveLoanInPast()) { @@ -218,7 +218,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } loan.undoApproval(defaultLoanLifecycleStateMachine()); @@ -243,7 +243,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotRejectLoanInPast()) { @@ -272,7 +272,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotWithdrawByClientLoanInPast()) { @@ -301,7 +301,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotDisburseLoanInPast()) { @@ -388,7 +388,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } if (loan.isActualDisbursedOnDateEarlierOrLaterThanExpected()) { @@ -418,7 +418,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } if (this.isBeforeToday(command.getTransactionDate()) && currentUser.canNotMakeRepaymentOnLoanInPast()) { @@ -453,7 +453,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } LoanTransaction transactionToAdjust = this.loanTransactionRepository @@ -495,7 +495,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), command.getLoanId())); if (loan == null) { - throw new PlatformResourceNotFoundException("error.msg.loan.id.invalid", "Loan with identifier {0} does not exist", command.getLoanId()); + throw new LoanNotFoundException(command.getLoanId()); } Money waived = Money.of(loan.getLoanRepaymentScheduleDetail()