This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/master by this push:
     new f5a39cc  Fix for NLPCRAFT-181.
f5a39cc is described below

commit f5a39cc993af8c7e691db1f084cf3304062ff183
Author: Aaron Radzinski <[email protected]>
AuthorDate: Sun Nov 29 18:21:39 2020 -0800

    Fix for NLPCRAFT-181.
---
 .../nlpcraft/model/tools/cmdline/NCCli.scala       | 53 ++++++++++++----------
 1 file changed, 30 insertions(+), 23 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 440a109..7667f10 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -1784,8 +1784,8 @@ object NCCli extends App {
                 ) acquireAndGet {
                     _.readObject()
                 }
-                )
-                .asInstanceOf[NCCliServerBeacon]
+            )
+            .asInstanceOf[NCCliServerBeacon]
 
             ProcessHandle.of(beacon.pid).asScala match {
                 case Some(ph) ⇒
@@ -1826,28 +1826,35 @@ object NCCli extends App {
 
                 val baseUrl = "http://"; + beacon.restEndpoint
 
-                // Attempt to signin with the default account.
-                if (autoSignIn && state.accessToken.isEmpty)
-                    httpPostResponseJson(
-                        baseUrl,
-                        "signin",
-                        "{\"email\": \"[email protected]\", \"passwd\": 
\"admin\"}") match {
-                        case Some(json) ⇒ state.accessToken = 
Option(Try(U.getJsonStringField(json, "acsTok")).getOrElse(null))
-                        case None ⇒ ()
-                    }
+                try {
+                    // Attempt to signin with the default account.
+                    if (autoSignIn && state.accessToken.isEmpty)
+                        httpPostResponseJson(
+                            baseUrl,
+                            "signin",
+                            "{\"email\": \"[email protected]\", \"passwd\": 
\"admin\"}") match {
+                            case Some(json) ⇒ state.accessToken = 
Option(Try(U.getJsonStringField(json, "acsTok")).getOrElse(null))
+                            case None ⇒ ()
+                        }
 
-                // Attempt to get all connected probes if successfully signed 
in prior.
-                if (state.accessToken.isDefined)
-                    httpPostResponseJson(
-                        baseUrl,
-                        "probe/all",
-                        "{\"acsTok\": \"" + state.accessToken.get + "\"}") 
match {
-                        case Some(json) ⇒ state.probes =
-                            Try(
-                                U.jsonToObject[ProbeAllResponse](json, 
classOf[ProbeAllResponse]).probes.toList
-                            ).getOrElse(Nil)
-                        case None ⇒ ()
-                    }
+                    // Attempt to get all connected probes if successfully 
signed in prior.
+                    if (state.accessToken.isDefined)
+                        httpPostResponseJson(
+                            baseUrl,
+                            "probe/all",
+                            "{\"acsTok\": \"" + state.accessToken.get + "\"}") 
match {
+                            case Some(json) ⇒ state.probes =
+                                Try(
+                                    U.jsonToObject[ProbeAllResponse](json, 
classOf[ProbeAllResponse]).probes.toList
+                                ).getOrElse(Nil)
+                            case None ⇒ ()
+                        }
+                }
+                catch {
+                    case _: Exception ⇒
+                        // Reset REPL state.
+                        state = ReplState()
+                }
 
             case None ⇒
                 // Reset REPL state.

Reply via email to