Skip to content

Commit

Permalink
[TRELLO-2781] Improve errors
Browse files Browse the repository at this point in the history
  • Loading branch information
charlescd committed Mar 4, 2025
1 parent 16f0a62 commit 4531102
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/controllers/error/AppError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,12 @@ object AppError {
s"Le signalement $id n'est pas réattribuable"
override val titleForLogs: String = "report_not_reattributable"
}

final case object CantReattributeToTheSameCompany extends BadRequestError {
override val scErrorCode: String = "SC-0073"
override val title: String = s"Report is not reattributable"
override val details: String =
"Vous ne pouvez pas réattribuer ce signalement à la même entreprise"
override val titleForLogs: String = "report_not_reattributable"
}
}
2 changes: 1 addition & 1 deletion app/orchestrators/ReportOrchestrator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ class ReportOrchestrator(
_ <- if (maybeProResponseDate.nonEmpty) Future.unit else Future.failed(ReportNotReattributable(reportId))
_ <- validateCompany(companyCreation.activityCode, Some(companyCreation.siret))
_ <-
if (report.companySiret.contains(companyCreation.siret)) Future.failed(ReportNotReattributable(reportId))
if (report.companySiret.contains(companyCreation.siret)) Future.failed(CantReattributeToTheSameCompany)
else Future.unit
company <- companyRepository.getOrCreate(companyCreation.siret, toCompany(companyCreation))
reportFilesMap <- reportFileOrchestrator.prefetchReportsFiles(List(reportId))
Expand Down

0 comments on commit 4531102

Please sign in to comment.