Skip to content

Commit 6a34415

Browse files
committed
Try to "normalize" existing not found error message in modules
1 parent 107d4bd commit 6a34415

File tree

12 files changed

+53
-50
lines changed

12 files changed

+53
-50
lines changed

common/src/main/kotlin/com/cosmotech/common/rbac/CsmRbac.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ open class CsmRbac(
105105
this.checkEntityExists(
106106
parentRbacSecurity,
107107
entityId,
108-
"Entity $entityId not found in parent ${parentRbacSecurity.id} component",
108+
"Entity '$entityId' not found in parent component '${parentRbacSecurity.id}'",
109109
)
110110
}
111111
return setEntityRole(rbacSecurity, entityId, role, rolesDefinition)
@@ -150,7 +150,7 @@ open class CsmRbac(
150150
fun getAccessControl(rbacSecurity: RbacSecurity, entityId: String): RbacAccessControl {
151151
return rbacSecurity.accessControlList.find { it.id == entityId }
152152
?: throw CsmResourceNotFoundException(
153-
"Entity $entityId not found in ${rbacSecurity.id} component"
153+
"Entity '$entityId' not found in component '${rbacSecurity.id}'"
154154
)
155155
}
156156

dataset/src/integrationTest/kotlin/com/cosmotech/dataset/service/DatasetServiceIntegrationTest.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -694,9 +694,9 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
694694
}
695695

696696
assertEquals(
697-
"Dataset $datasetId not found " +
698-
"in organization ${organizationSaved.id} " +
699-
"and workspace ${workspaceSaved.id}",
697+
"Dataset '$datasetId' not found " +
698+
"in Organization '${organizationSaved.id}' " +
699+
"and Workspace '${workspaceSaved.id}'",
700700
exception.message,
701701
)
702702
}
@@ -760,9 +760,9 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
760760
}
761761

762762
assertEquals(
763-
"Dataset $datasetId not found " +
764-
"in organization ${organizationSaved.id} " +
765-
"and workspace ${workspaceSaved.id}",
763+
"Dataset '$datasetId' not found " +
764+
"in Organization '${organizationSaved.id}' " +
765+
"and Workspace '${workspaceSaved.id}'",
766766
exception.message,
767767
)
768768

@@ -2484,8 +2484,8 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
24842484
}
24852485

24862486
assertEquals(
2487-
"Dataset Part wrongDatasetPartId not found in organization ${organizationSaved.id}, " +
2488-
"workspace ${workspaceSaved.id} and dataset ${createDataset.id}",
2487+
"Dataset part 'wrongDatasetPartId' not found in Organization '${organizationSaved.id}', " +
2488+
"Workspace '${workspaceSaved.id}' and Dataset '${createDataset.id}'",
24892489
exception.message,
24902490
)
24912491
}
@@ -2813,9 +2813,9 @@ class DatasetServiceIntegrationTest() : CsmTestBase() {
28132813
)
28142814
}
28152815
assertEquals(
2816-
"Dataset Part ${createdDataset.parts[0].id} not found " +
2817-
"in organization ${organizationSaved.id}, " +
2818-
"workspace ${workspaceSaved.id} and dataset ${createdDataset.id}",
2816+
"Dataset part '${createdDataset.parts[0].id}' not found " +
2817+
"in Organization '${organizationSaved.id}', " +
2818+
"Workspace '${workspaceSaved.id}' and Dataset '${createdDataset.id}'",
28192819
oldDatasetPartShouldNotExistInDB.message,
28202820
)
28212821

dataset/src/main/kotlin/com/cosmotech/dataset/service/DatasetServiceImpl.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class DatasetServiceImpl(
8181
val dataset =
8282
datasetRepository.findBy(organizationId, workspaceId, datasetId).orElseThrow {
8383
CsmResourceNotFoundException(
84-
"Dataset $datasetId not found in organization $organizationId and workspace $workspaceId"
84+
"Dataset '$datasetId' not found in Organization '$organizationId' and Workspace '$workspaceId'"
8585
)
8686
}
8787
csmRbac.verify(dataset.security.toGenericSecurity(datasetId), requiredPermission)
@@ -96,7 +96,7 @@ class DatasetServiceImpl(
9696
workspaceService.getVerifiedWorkspace(organizationId, workspaceId)
9797
return datasetRepository.findBy(organizationId, workspaceId, datasetId).orElseThrow {
9898
CsmResourceNotFoundException(
99-
"Dataset $datasetId not found in organization $organizationId and workspace $workspaceId"
99+
"Dataset '$datasetId' not found in Organization '$organizationId' and Workspace '$workspaceId'"
100100
)
101101
}
102102
}
@@ -402,7 +402,7 @@ class DatasetServiceImpl(
402402
csmRbac.checkEntityExists(
403403
dataset.security.toGenericSecurity(datasetId),
404404
identityId,
405-
"User '$identityId' not found in dataset $datasetId",
405+
"User '$identityId' not found in Dataset '$datasetId'",
406406
)
407407
val rbacSecurity =
408408
csmRbac.setEntityRole(
@@ -527,8 +527,8 @@ class DatasetServiceImpl(
527527
.findBy(organizationId, workspaceId, datasetId, datasetPartId)
528528
.orElseThrow {
529529
CsmResourceNotFoundException(
530-
"Dataset Part $datasetPartId not found in organization $organizationId, " +
531-
"workspace $workspaceId and dataset $datasetId"
530+
"Dataset part '$datasetPartId' not found in Organization '$organizationId', " +
531+
"Workspace '$workspaceId' and Dataset '$datasetId'"
532532
)
533533
}
534534

@@ -559,8 +559,8 @@ class DatasetServiceImpl(
559559
.findBy(organizationId, workspaceId, datasetId, datasetPartId)
560560
.orElseThrow {
561561
CsmResourceNotFoundException(
562-
"Dataset Part $datasetPartId not found in organization $organizationId, " +
563-
"workspace $workspaceId and dataset $datasetId"
562+
"Dataset part '$datasetPartId' not found in Organization '$organizationId', " +
563+
"Workspace '$workspaceId' and Dataset '$datasetId'"
564564
)
565565
}
566566
}
@@ -856,8 +856,8 @@ class DatasetServiceImpl(
856856
.findBy(organizationId, workspaceId, datasetId, datasetPartId)
857857
.orElseThrow {
858858
CsmResourceNotFoundException(
859-
"Dataset Part $datasetPartId not found in organization $organizationId, " +
860-
"workspace $workspaceId and dataset $datasetId"
859+
"Dataset part '$datasetPartId' not found in Organization '$organizationId', " +
860+
"Workspace '$workspaceId' and Dataset '$datasetId'"
861861
)
862862
}
863863
val now = Instant.now().toEpochMilli()
@@ -900,8 +900,8 @@ class DatasetServiceImpl(
900900
.findBy(organizationId, workspaceId, datasetId, datasetPartId)
901901
.orElseThrow {
902902
CsmResourceNotFoundException(
903-
"Dataset Part $datasetPartId not found in organization $organizationId, " +
904-
"workspace $workspaceId and dataset $datasetId"
903+
"Dataset part '$datasetPartId' not found in Organization '$organizationId', " +
904+
"Workspace '$workspaceId' and Dataset '$datasetId'"
905905
)
906906
}
907907

@@ -1012,7 +1012,7 @@ class DatasetServiceImpl(
10121012
val dataset =
10131013
datasetRepository.findBy(organizationId, workspaceId, datasetParameterId).orElseThrow {
10141014
CsmResourceNotFoundException(
1015-
"Dataset $datasetParameterId not found in organization $organizationId and workspace $workspaceId"
1015+
"Dataset '$datasetParameterId' not found in Organization '$organizationId' and Workspace '$workspaceId'"
10161016
)
10171017
}
10181018

organization/src/main/kotlin/com/cosmotech/organization/service/OrganizationServiceImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class OrganizationServiceImpl(
219219
csmRbac.checkEntityExists(
220220
organization.security.toGenericSecurity(organizationId),
221221
identityId,
222-
"User '$identityId' not found in organization $organizationId",
222+
"User '$identityId' not found in Organization '$organizationId'",
223223
)
224224
val rbacSecurity =
225225
csmRbac.setEntityRole(

run/src/main/kotlin/com/cosmotech/run/RunContainerFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class RunContainerFactory(
213213
private fun getRunTemplate(solution: Solution, runTemplateId: String): RunTemplate {
214214
return solution.runTemplates.find { runTemplate -> runTemplate.id == runTemplateId }
215215
?: throw IllegalStateException(
216-
"runTemplateId $runTemplateId not found in Solution ${solution.id}"
216+
"RunTemplateId '$runTemplateId' not found in Solution '${solution.id}'"
217217
)
218218
}
219219

run/src/main/kotlin/com/cosmotech/run/service/RunServiceImpl.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import com.cosmotech.common.events.RunStart
88
import com.cosmotech.common.events.RunStop
99
import com.cosmotech.common.events.RunnerDeleted
1010
import com.cosmotech.common.events.UpdateRunnerStatus
11+
import com.cosmotech.common.exceptions.CsmResourceNotFoundException
1112
import com.cosmotech.common.id.generateId
1213
import com.cosmotech.common.rbac.CsmRbac
1314
import com.cosmotech.common.rbac.PERMISSION_DELETE
@@ -142,8 +143,9 @@ class RunServiceImpl(
142143
runRepository
143144
.findBy(organizationId, workspaceId, runnerId, runId)
144145
.orElseThrow {
145-
throw IllegalArgumentException(
146-
"Run #$runId not found in #$runnerId. In #$workspaceId, #$organizationId."
146+
throw CsmResourceNotFoundException(
147+
"Run '$runId' not found in Organization '$organizationId', " +
148+
"Workspace '$workspaceId' and Runner '$runnerId'"
147149
)
148150
}
149151
.withStateInformation()
@@ -306,8 +308,9 @@ class RunServiceImpl(
306308
runRepository
307309
.findBy(organizationId, workspaceId, runnerId, runId)
308310
.orElseThrow {
309-
throw IllegalArgumentException(
310-
"Run #$runId not found in #$runnerId. In #$workspaceId, #$organizationId."
311+
throw CsmResourceNotFoundException(
312+
"Run '$runId' not found in Organization '$organizationId', " +
313+
"Workspace '$workspaceId' and Runner '$runnerId'"
311314
)
312315
}
313316
.withStateInformation()

runner/src/integrationTest/kotlin/com/cosmotech/runner/service/RunnerServiceIntegrationTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,9 +975,9 @@ class RunnerServiceIntegrationTest : CsmTestBase() {
975975
datasetApiService.getDataset(organizationSaved.id, workspaceSaved.id, parameterDatasetId)
976976
}
977977
assertEquals(
978-
"Dataset $parameterDatasetId not found " +
979-
"in organization ${organizationSaved.id} " +
980-
"and workspace ${workspaceSaved.id}",
978+
"Dataset '$parameterDatasetId' not found " +
979+
"in Organization '${organizationSaved.id}' " +
980+
"and Workspace '${workspaceSaved.id}'",
981981
exception.message,
982982
)
983983
}
@@ -1318,7 +1318,7 @@ class RunnerServiceIntegrationTest : CsmTestBase() {
13181318
"id",
13191319
)
13201320
}
1321-
assertEquals("Entity id not found in ${retrievedDataset.id} component", exception.message)
1321+
assertEquals("Entity 'id' not found in component '${retrievedDataset.id}'", exception.message)
13221322
}
13231323

13241324
@Test

runner/src/main/kotlin/com/cosmotech/runner/service/RunnerService.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class RunnerService(
212212
var runner =
213213
runnerRepository.findBy(organization!!.id, workspace!!.id, runnerId).orElseThrow {
214214
CsmResourceNotFoundException(
215-
"Runner $runnerId not found in workspace ${workspace!!.id} and organization ${organization!!.id}"
215+
"Runner '$runnerId' not found in Organization '${organization!!.id}' and Workspace '${workspace!!.id}'"
216216
)
217217
}
218218
if (
@@ -679,7 +679,7 @@ class RunnerService(
679679
)
680680
} else {
681681
logger.warn(
682-
"Parameter $parameterId not found in parent ($parentId) dataset parameters: " +
682+
"Parameter '$parameterId' not found in parent Dataset '$parentId' parameters: " +
683683
"No dataset part will be created"
684684
)
685685
}
@@ -849,7 +849,7 @@ class RunnerService(
849849
csmRbac.checkEntityExists(
850850
runner.getRbac(),
851851
userId,
852-
"User '$userId' not found in runner ${runner.id}",
852+
"User '$userId' not found in Runner '${runner.id}'",
853853
)
854854
}
855855

@@ -976,7 +976,7 @@ class RunnerService(
976976
parametersValuesList.add(parameterValue)
977977
} else {
978978
logger.warn(
979-
"Parameter $parameterId not found in parent ($parentId) parameters values"
979+
"Parameter '$parameterId' not found in parent Runner '$parentId' parameters values"
980980
)
981981
}
982982
}

solution/src/integrationTest/kotlin/com/cosmotech/solution/service/SolutionServiceIntegrationTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() {
436436
)
437437
}
438438
assertEquals(
439-
"Solution non-existing-solution-id not found in organization ${organizationSaved.id}",
439+
"Solution 'non-existing-solution-id' not found in Organization '${organizationSaved.id}'",
440440
exception.message,
441441
)
442442
}
@@ -732,7 +732,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() {
732732
)
733733
}
734734
assertEquals(
735-
"Solution non-existing-solution-id not found in organization ${organizationSaved.id}",
735+
"Solution 'non-existing-solution-id' not found in Organization '${organizationSaved.id}'",
736736
exception.message,
737737
)
738738
}
@@ -1514,7 +1514,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() {
15141514
)
15151515
}
15161516
assertEquals(
1517-
"Solution non-existing-solution-id not found in organization ${organizationSaved.id}",
1517+
"Solution 'non-existing-solution-id' not found in Organization '${organizationSaved.id}'",
15181518
exception.message,
15191519
)
15201520
}
@@ -1766,7 +1766,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() {
17661766
)
17671767
}
17681768
assertEquals(
1769-
"Solution non-existing-solution-id not found in organization ${organizationSaved.id}",
1769+
"Solution 'non-existing-solution-id' not found in Organization '${organizationSaved.id}'",
17701770
exception.message,
17711771
)
17721772
}
@@ -1891,7 +1891,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() {
18911891
solutionApiService.listRunTemplates(organizationSaved.id, "non-existing-solution-id")
18921892
}
18931893
assertEquals(
1894-
"Solution non-existing-solution-id not found in organization ${organizationSaved.id}",
1894+
"Solution 'non-existing-solution-id' not found in Organization '${organizationSaved.id}'",
18951895
exception.message,
18961896
)
18971897
}
@@ -2297,7 +2297,7 @@ class SolutionServiceIntegrationTest : CsmTestBase() {
22972297
)
22982298
}
22992299
assertEquals(
2300-
"Solution non-existing-solution-id not found in organization ${organizationSaved.id}",
2300+
"Solution 'non-existing-solution-id' not found in Organization '${organizationSaved.id}'",
23012301
exception.message,
23022302
)
23032303
}

solution/src/main/kotlin/com/cosmotech/solution/service/SolutionServiceImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ class SolutionServiceImpl(
585585
csmRbac.checkEntityExists(
586586
solution.security.toGenericSecurity(solutionId),
587587
identityId,
588-
"User '$identityId' not found in solution $solutionId",
588+
"User '$identityId' not found in Solution '$solutionId'",
589589
)
590590
val rbacSecurity =
591591
csmRbac.setEntityRole(
@@ -626,7 +626,7 @@ class SolutionServiceImpl(
626626
val solution =
627627
solutionRepository.findBy(organizationId, solutionId).orElseThrow {
628628
CsmResourceNotFoundException(
629-
"Solution $solutionId not found in organization $organizationId"
629+
"Solution '$solutionId' not found in Organization '$organizationId'"
630630
)
631631
}
632632
csmRbac.verify(solution.security.toGenericSecurity(solutionId), requiredPermission)

0 commit comments

Comments
 (0)