Last active
January 5, 2020 00:44
-
-
Save pjambet/b4459f8f189f6e3f59087036b6dd0b30 to your computer and use it in GitHub Desktop.
Exeception handling in the controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case Failure(exception) => | |
exception match { | |
case e: CardException => | |
complete( | |
StatusCodes.PaymentRequired, | |
HttpEntity( | |
ContentTypes.`application/json`, | |
"{\"message\": \"Invalid card\", \"code\": \"" + e.declineCode + "\"}")) | |
case _ => | |
system.log.error(exception, "Unexpected error") | |
complete( | |
StatusCodes.InternalServerError, | |
HttpEntity(ContentTypes.`application/json`, | |
"{\"message\": \"Something went wrong\"}")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment