Skip to content

Commit 75924ca

Browse files
Fixed caught error reporting, WebTerminal core refactoring
1 parent 9aaf181 commit 75924ca

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"printableName": "Cache Web Terminal",
66
"description": "Web-based terminal emulator for Caché administering.",
77
"author": "ZitRo",
8-
"version": "4.2.15",
8+
"version": "4.3.0",
99
"gaID": "UA-83005064-2",
1010
"releaseNumber": 26,
1111
"scripts": {

src/cls/WebTerminal/Core.cls

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -329,41 +329,58 @@ ClassMethod WaitCommand() As %String [ ProcedureBlock = 1 ]
329329
}
330330

331331
/// Starts new terminal loop. Must be called with JOB command.
332-
ClassMethod Loop(StartupRoutine As %String = "") As %Status
332+
ClassMethod Loop(startupRoutine As %String = "") As %Status
333333
{
334334
if ($ZPARENT = 0) {
335335
write "This method is for JOB use only."
336336
return 0
337337
}
338338
open "terminal"::"^%X364"
339339
use $io::"^" _ $ZName
340-
if (StartupRoutine '= "") {
341-
do $System.Util.SetInterruptEnable($$$YES)
342-
do ##class(%Device).ReDirectIO($$$YES)
343-
try {
344-
do @StartupRoutine
345-
do ##class(%Device).ReDirectIO($$$NO)
346-
} catch {
347-
do ##class(%Device).ReDirectIO($$$NO)
348-
do ..SendChunk($ZPARENT, "e", $LISTBUILD($NAMESPACE, $ZERROR))
349-
}
350-
do ..SendChunk($ZPARENT, "e", $LISTBUILD($NAMESPACE, ""))
351-
return $$$OK
340+
if (startupRoutine '= "") {
341+
return ..StartupRoutine(startupRoutine)
352342
}
353-
kill // kill any temporary variables ProcedureBlock may have
343+
kill // Kill any temporary variables ProcedureBlock may have. Keep procedure block free of vars
354344
for {
355-
do ##class(%Device).ReDirectIO($$$YES)
356-
do $System.Util.SetInterruptEnable($$$YES)
357-
set $ZERROR = ""
345+
do ..StartExecMode()
358346
try {
359347
xecute ..WaitCommand()
360-
use $io::"^" _ $ZName
361-
} catch {}
362-
do ##class(%Device).ReDirectIO($$$NO)
363-
write !! // assume that prompt takes 2 lines
364-
do ..SendChunk($ZPARENT, "e", $LISTBUILD($NAMESPACE, $ZERROR))
348+
} catch err {
349+
do ..EndExecMode($ZERROR)
350+
continue
351+
}
352+
do ..EndExecMode()
365353
}
366354
return $$$OK
367355
}
368356

357+
ClassMethod StartupRoutine(routineName = "") As %Status
358+
{
359+
do ..StartExecMode()
360+
try {
361+
do @routineName
362+
} catch {
363+
do ..EndExecMode($ZERROR)
364+
return $$$OK
365+
}
366+
do ..EndExecMode()
367+
return $$$OK
368+
}
369+
370+
ClassMethod StartExecMode()
371+
{
372+
write ! // Y pos shift
373+
do ##class(%Device).ReDirectIO($$$YES)
374+
do $System.Util.SetInterruptEnable($$$YES)
375+
}
376+
377+
ClassMethod EndExecMode(error = "")
378+
{
379+
use $io::"^" _ $ZName
380+
do $System.Util.SetInterruptEnable($$$NO)
381+
do ##class(%Device).ReDirectIO($$$NO)
382+
write ! // Y pos shift
383+
do ..SendChunk($ZPARENT, "e", $LISTBUILD($NAMESPACE, error))
384+
}
385+
369386
}

src/cls/WebTerminal/Handlers.cls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ loop
7373
##class(ErrorDecomposer).DecomposeError(err, client.childNamespace)
7474
)
7575
}
76-
quit // break for cycle
76+
quit // break for loop
7777
} else { // unknown response - just send it to the client
7878
do client.Send("o", chunk)
7979
}

0 commit comments

Comments
 (0)