Skip to content

Instantly share code, notes, and snippets.

@dkomanov
Created January 9, 2016 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dkomanov/eb3c043a1752c9c4ab31 to your computer and use it in GitHub Desktop.
Save dkomanov/eb3c043a1752c9c4ab31 to your computer and use it in GitHub Desktop.
[scala] result code: either with some implicits
def processRequestNew(userId: UUID, requestId: UUID): BusinessResult = {
for {
user <- getUser(userId) orResult BusinessResult.UserNotFound
request <- getRequestById(requestId) orResult BusinessResult.RequestNotFound
_ <- checkAccess(request, user) orResult BusinessResult.NotOwner
} yield BusinessResult.Ok
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment