Skip to content

Commit

Permalink
add some error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Büßemeyer authored and Michael Büßemeyer committed Dec 2, 2024
1 parent d531a26 commit ede5197
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/controllers/DatasetController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class DatasetController @Inject()(userService: UserService,
searchQuery,
recursive.getOrElse(false),
limit) ?~> "dataset.list.failed"
js <- listGrouped(datasets, request.identity) ?~> "dataset.list.failed"
js <- listGrouped(datasets, request.identity) ?~> "dataset.list.grouping.failed"
} yield Json.toJson(js)
}
_ = Fox.runOptional(request.identity)(user => userDAO.updateLastActivity(user._id))
Expand All @@ -223,7 +223,7 @@ class DatasetController @Inject()(userService: UserService,
groupedByOrga = datasets.groupBy(_._organization).toList
js <- Fox.serialCombined(groupedByOrga) { byOrgaTuple: (String, List[Dataset]) =>
for {
organization <- organizationDAO.findOne(byOrgaTuple._1)(GlobalAccessContext)
organization <- organizationDAO.findOne(byOrgaTuple._1)(GlobalAccessContext) ?~> "organization.notFound"
groupedByDataStore = byOrgaTuple._2.groupBy(_._dataStore).toList
result <- Fox.serialCombined(groupedByDataStore) { byDataStoreTuple: (String, List[Dataset]) =>
for {
Expand Down
2 changes: 1 addition & 1 deletion app/models/dataset/DataStore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class DataStoreDAO @Inject()(sqlClient: SqlClient)(implicit ec: ExecutionContext
for {
accessQuery <- readAccessQuery
r <- run(q"SELECT $columns FROM $existingCollectionName WHERE name = $name AND $accessQuery".as[DatastoresRow])
parsed <- parseFirst(r, name)
parsed <- parseFirst(r, name) ?~> "dataStore.notFound"
} yield parsed

def findOneByUrl(url: String)(implicit ctx: DBAccessContext): Fox[DataStore] =
Expand Down
2 changes: 1 addition & 1 deletion app/models/dataset/DatasetService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class DatasetService @Inject()(organizationDAO: OrganizationDAO,
organizationDAO.findOne(dataset._organization) ?~> "organization.notFound"
}
dataStore <- Fox.fillOption(dataStore) {
dataStoreFor(dataset)
dataStoreFor(dataset) ?~> "dataStore.notFound"
}
teams <- teamService.allowedTeamsForDataset(dataset, cumulative = false, requestingUserOpt) ?~> "dataset.list.fetchAllowedTeamsFailed"
teamsJs <- Fox.serialCombined(teams)(t => teamService.publicWrites(t, Some(organization))) ?~> "dataset.list.teamWritesFailed"
Expand Down
4 changes: 2 additions & 2 deletions app/models/user/UserService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ class UserService @Inject()(conf: WkConf,
userExperiencesDAO.findAllExperiencesForUser(_user)

def teamMembershipsFor(_user: ObjectId): Fox[List[TeamMembership]] =
userDAO.findTeamMembershipsForUser(_user)
userDAO.findTeamMembershipsForUser(_user) ?~> "user.team.memberships.failed"

def teamManagerMembershipsFor(_user: ObjectId): Fox[List[TeamMembership]] =
for {
teamMemberships <- teamMembershipsFor(_user)
teamMemberships <- teamMembershipsFor(_user) ?~> "user.team.memberships.failed"
} yield teamMemberships.filter(_.isTeamManager)

def teamManagerTeamIdsFor(_user: ObjectId): Fox[List[ObjectId]] =
Expand Down
4 changes: 3 additions & 1 deletion conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ user.notAuthorised=You are not authorized to view this resource. Please log in.
user.id.notFound=We could not find a user id in the request.
user.id.invalid=The provided user id is invalid.
user.creation.failed=Failed to create user
user.team.memberships.failed=Failed to retrieve team memberships for user

oidc.disabled=OIDC is disabled
oidc.configuration.invalid=OIDC configuration is invalid
Expand All @@ -88,7 +89,8 @@ dataset.name.alreadyTaken=This name is already being used by a different dataset
dataset.source.usableButNoScale=Dataset {0} is marked as active but has no scale.
dataset.import.fileAccessDenied=Cannot create organization folder. Please make sure WEBKNOSSOS has write permissions in the “binaryData” directory
dataset.type.invalid=External data set of type “{0}” is not supported
dataset.list.failed=Failed to retrieve list of data sets.
dataset.list.failed=Failed to retrieve list of datasets.
dataset.list.grouping.failed=Failed group retrieved datasets.
dataset.list.writesFailed=Failed to write json for dataset {0}
dataset.noMags=Data layer does not contain mags
dataset.sampledOnlyBlack=Sampled data positions contained only black data
Expand Down

0 comments on commit ede5197

Please sign in to comment.