-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved server side JSON validation #188
Conversation
} | ||
|
||
val updatedAtom = PublishAtomCommand(id).process() | ||
Ok(Json.toJson(updatedAtom)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we've removed the try/catch
what happens when PublishAtomCommand(id).process()
throws? Do we get a 500 and a sensible message still?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry. I've put back the try/catch
} | ||
} | ||
|
||
def getAuditTrailForAtomId(id: String) = APIHMACAuthAction { implicit req => | ||
Ok(Json.toJson(auditDataStore.getAuditTrailForAtomId(id))) | ||
} | ||
|
||
private def parse[T](raw: UserRequest[AnyContent])(fn: T => Result)(implicit reads: Reads[T]): Result = try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
@@ -2,23 +2,23 @@ package controllers | |||
|
|||
import javax.inject.Inject | |||
|
|||
import _root_.util.{AWSConfig, ExpiryPoller, YouTubeConfig, YouTubeVideoUpdateApi} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_root_
silly intellij!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I double checked it was like that before I changed things
Refactored out JSON validation in
Api2
into a single method, which returns aBadRequest
response detailing the errors.For example, missing out fields in the
create
UI no longer causes a 500 but returns a list of the missing fields:Also update the front-end to clear out saving/publishing/searching state when an error occurs. This stops the save button from spinning forever.
NB: the error still shows up in red at the top forever (#187)