gpt4 book ai didi

mongodb - Scala 和 Playframework : what they mean with ExecutionException: Boxed Error

转载 作者:可可西里 更新时间:2023-11-01 09:52:16 25 4
gpt4 key购买 nike

什么是 ExecutionException:盒装错误?还有可能使它更具可读性或更具体吗?请参阅下面的代码。

有用的提示:在我添加 yrBuilt 之后,一切都出错了!

显示的错误是:

java.util.concurrent.ExecutionException: Boxed Error
at scala.concurrent.impl.Promise$.resolver(Promise.scala:52) ~[scala-library.jar:na]
at scala.concurrent.impl.Promise$.scala$concurrent$impl$Promise$$resolveTry(Promise.scala:44) ~[scala-library.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.tryComplete(Promise.scala:116) ~[scala-library.jar:na]
at scala.concurrent.Promise$class.complete(Promise.scala:55) ~[scala-library.jar:na]
at scala.concurrent.impl.Promise$DefaultPromise.complete(Promise.scala:58) ~[scala-library.jar:na]
at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:23) [scala-library.jar:na]
Caused by: java.lang.Error: could not parse form
at controllers.SnoopController$$anonfun$11.apply(SnoopController.scala:187) ~[classes/:na]
at controllers.SnoopController$$anonfun$11.apply(SnoopController.scala:186) ~[classes/:na]
at play.api.data.Form$$anonfun$fold$2.apply(Form.scala:134) ~[play_2.10-2.1.1.jar:2.1.1]
at scala.Option.getOrElse(Option.scala:120) [scala-library.jar:na]
at play.api.data.Form.fold(Form.scala:134) ~[play_2.10-2.1.1.jar:2.1.1]
at controllers.SnoopController$.getPropertyFromRequest(SnoopController.scala:185) ~[classes/:na]

代码:在 View 部分

<div class="inputGroup">
<div class="efInput">
<label for="year_built">Year Built:</label>
<input type="text" id="lotsize" name="year_built" value="@property.yrBuilt">
</div>
</div>

Controller 部分:

    def getPropertyFromRequest(implicit request: Request[AnyContent]): (Property, Option[ObjectId], Option[ObjectId]) = {
val p =
Form(tuple(
"desc" -> text,
"url" -> text,
"image" -> text,
"price" -> text,
"sqft" -> text,
"address2" -> text,
"lotsize" -> text,
"taxes" -> text,
"status" -> optional(text),
"maint" -> text,
"address" -> text,
"mls" -> text,
"baths" -> text,
"beds" -> text,
"partial_baths" -> text,
"propertyId" -> optional(text),
"snoopId" -> optional(text),
"yrBuilt" -> text
)).bindFromRequest().fold(
errors => {Logger.error(errors.toString())
throw new Error("could not parse form")},
success => success
)

val a = GeoCoder.create(p._11 + " " + p._6)
val property = Property(url = p._2,
description = p._1,
image = p._3,
price = parseAmount(p._4).toDouble,
sqft = p._5,
lotSize = p._7,
taxes = parseAmount(p._8),
status = PropertyStatus.ACTIVE,
maintenance = parseAmount(p._10),
mls = p._12,
baths = try{p._13.toDouble}catch{case e => 0},
beds = try{p._14.toInt}catch{case e=> 0},
partialBaths = try{p._15.toDouble}catch{case e => 0},
address = a,
yrBuilt = p._18)

(property,p._16.map(new ObjectId(_)),p._17.map(new ObjectId(_)))
}

模型部分:

case class Property(
id: ObjectId = new ObjectId,
parentId: Option[ObjectId] = None,
url: String,
price: Double,
parentPrice: Option[Double] = None,
beds: Int,
baths: Double,
partialBaths: Double = 0.0,
address: Address,
mls: String,
sqft: String,
lotSize: String,
taxes: Int,
maintenance: Int,
description: String,
image: String,
status: PropertyStatus.Value = PropertyStatus.ACTIVE,
updated: Date = new Date(),
priceHistory: List[PriceChange] = Nil,
failedSnoops: Int = 0,
yrBuilt: String
) {
def monthlyFees: Double = {
val t = try { taxes / 12 } catch { case e: Exception => 0 }
val m = try { maintenance / 12 } catch { case e: Exception => 0 }
t + m
}

def diff(that: Property): List[(String,Any,Any)] = {
var changes: List[(String,Any,Any)] = Nil
if (this.url != that.url) changes = ("url", this.url, that.url) :: changes
if (this.price != that.price) changes = ("price", this.price, that.price) :: changes
if (this.beds != that.beds) changes = ("beds", this.beds, that.beds) :: changes
if (this.baths != that.baths) changes = ("baths", this.baths, that.baths) :: changes
if (this.partialBaths != that.partialBaths) changes = ("partialBaths", this.partialBaths, that.partialBaths) :: changes
if (this.address != that.address) changes = ("address", this.address, that.address) :: changes
if (this.mls != that.mls) changes = ("mls", this.mls, that.mls) :: changes
if (this.sqft != that.sqft) changes = ("sqft", this.sqft, that.sqft) :: changes
if (this.lotSize != that.lotSize) changes = ("lotSize", this.lotSize, that.lotSize) :: changes
if (this.taxes != that.taxes) changes = ("taxes", this.taxes, that.taxes) :: changes
if (this.maintenance != that.maintenance) changes = ("maintenance", this.maintenance, that.maintenance) :: changes
if (this.description != that.description) changes = ("description", this.description, that.description) :: changes
if (this.yrBuilt != that.yrBuilt) changes = ("yrBuilt", this.yrBuilt, that.yrBuilt) :: changes
changes
}
}

最佳答案

看起来它正在努力解析您的表单,原因可能是它找不到 yrBuild 字段。您已经覆盖了该字段的默认 ID/名称。尝试:

<input type="text" id="yrBuilt" name="yrBuilt" value="@property.yrBuilt">

关于mongodb - Scala 和 Playframework : what they mean with ExecutionException: Boxed Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22406615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com