Skip to content

Commit

Permalink
Updated error support in Scala.js
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Jul 17, 2018
1 parent dd723c4 commit d7cc96b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -7,6 +7,7 @@
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/outr/youi)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.youi/youi-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.youi/youi-core_2.12)
[![Latest version](https://index.scala-lang.org/outr/youi/youi-core/latest.svg)](https://index.scala-lang.org/outr/youi)
[![Javadocs](https://javadoc.io/badge/io.youi/youi-core_2.12.svg)](https://javadoc.io/doc/io.youi/youi-core_2.12)

Next generation user interface and application development in Scala and Scala.js for web, mobile, and desktop.

Expand Down
9 changes: 7 additions & 2 deletions app/js/src/main/scala/io/youi/app/ClientApplication.scala
Expand Up @@ -14,6 +14,7 @@ import scribe.writer.Writer
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.scalajs.js
import scala.scalajs.js.|

trait ClientApplication extends YouIApplication with ScreenManager {
ClientApplication.instance = this
Expand All @@ -25,8 +26,12 @@ trait ClientApplication extends YouIApplication with ScreenManager {

def clientConnectivity(connectivity: ApplicationConnectivity): ClientConnectivity = configuredConnectivity(connectivity)

private val errorFunction: js.Function5[String, String, Int, Int, Throwable, Unit] = (message: String, source: String, line: Int, column: Int, throwable: Throwable) => {
ErrorTrace.toError(message, source, line, column, Option(throwable)).map(ClientApplication.sendError)
private val errorFunction: js.Function5[String, String, Int, Int, Throwable | js.Error, Unit] = (message: String, source: String, line: Int, column: Int, err: Throwable | js.Error) => {
err match {
case null => ErrorTrace.toError(message, source, line, column, None).map(ClientApplication.sendError)
case t: Throwable => ErrorTrace.toError(message, source, line, column, Some(t)).map(ClientApplication.sendError)
case e: js.Error => ErrorTrace.toError(message, source, line, column, Some(js.JavaScriptException(e))).map(ClientApplication.sendError)
}
()
}

Expand Down

0 comments on commit d7cc96b

Please sign in to comment.