Skip to content

Commit

Permalink
rewrite error strings & remove my debug error info
Browse files Browse the repository at this point in the history
  • Loading branch information
OldLiu001 committed Jan 28, 2023
1 parent d44cddb commit 51cd399
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 34 deletions.
2 changes: 1 addition & 1 deletion impls/vbs/core.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ Function MNth(objArgs, objEnv)
Set varRes = objArgs.Item(1).Item(objArgs.Item(2).Value)
Else
Err.Raise vbObjectError, _
"MNth", "Index out of bound."
"MNth", "Index out of bounds."
End If

Set MNth = varRes
Expand Down
2 changes: 1 addition & 1 deletion impls/vbs/env.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Class Environment
Set varRet = objOuter.Find(varKey)
Else
Err.Raise vbObjectError, _
"Environment", "Symbol '" + varKey.Value + "' not found."
"Environment", "'" + varKey.Value + "' not found"
End If
End If

Expand Down
22 changes: 11 additions & 11 deletions impls/vbs/reader.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Function ReadString(strCode)
Set ReadString = ReadForm(objTokens)
If Not objTokens.AtEnd() Then
Err.Raise vbObjectError, _
"ReadForm", "Extra token '" + objTokens.Current() + "'."
"ReadForm", "extra token '" + objTokens.Current() + "'."
End If
End Function

Expand Down Expand Up @@ -91,7 +91,7 @@ Function ReadForm(objTokens) ' Return Nothing / MalType
Set varResult = ReadSpecial(objTokens)
ElseIf InStr(")]}", strToken) Then
Err.Raise vbObjectError, _
"ReadForm", "Unbalanced parentheses."
"ReadForm", "unbalanced parentheses."
ElseIf strToken = "^" Then
Set varResult = ReadMetadata(objTokens)
Else
Expand Down Expand Up @@ -132,7 +132,7 @@ Function ReadSpecial(objTokens)
strAlias = "deref"
Case Else
Err.Raise vbObjectError, _
"ReadSpecial", "Unknown token '" & strAlias & "'."
"ReadSpecial", "unknown token '" & strAlias & "'."
End Select

Call objTokens.MoveToNext()
Expand All @@ -149,7 +149,7 @@ Function ReadList(objTokens)

If objTokens.AtEnd() Then
Err.Raise vbObjectError, _
"ReadList", "Unbalanced parentheses."
"ReadList", "unbalanced parentheses."
End If

Set varResult = NewMalList(Array())
Expand All @@ -161,7 +161,7 @@ Function ReadList(objTokens)

If objTokens.MoveToNext() <> ")" Then
Err.Raise vbObjectError, _
"ReadList", "Unbalanced parentheses."
"ReadList", "unbalanced parentheses."
End If

Set ReadList = varResult
Expand All @@ -173,7 +173,7 @@ Function ReadVector(objTokens)

If objTokens.AtEnd() Then
Err.Raise vbObjectError, _
"ReadVector", "Unbalanced parentheses."
"ReadVector", "unbalanced parentheses."
End If

Set varResult = NewMalVec(Array())
Expand All @@ -185,7 +185,7 @@ Function ReadVector(objTokens)

If objTokens.MoveToNext() <> "]" Then
Err.Raise vbObjectError, _
"ReadVector", "Unbalanced parentheses."
"ReadVector", "unbalanced parentheses."
End If

Set ReadVector = varResult
Expand All @@ -197,7 +197,7 @@ Function ReadHashmap(objTokens)

If objTokens.Count = 0 Then
Err.Raise vbObjectError, _
"ReadHashmap", "Unbalanced parentheses."
"ReadHashmap", "unbalanced parentheses."
End If

Set varResult = NewMalMap(Array(), Array())
Expand All @@ -212,7 +212,7 @@ Function ReadHashmap(objTokens)

If objTokens.MoveToNext() <> "}" Then
Err.Raise vbObjectError, _
"ReadHashmap", "Unbalanced parentheses."
"ReadHashmap", "unbalanced parentheses."
End If

Set ReadHashmap = varResult
Expand Down Expand Up @@ -252,7 +252,7 @@ End Function
Function ParseString(strRaw)
If Right(strRaw, 1) <> """" Or Len(strRaw) < 2 Then
Err.Raise vbObjectError, _
"ParseString", "Unterminated string, got EOF."
"ParseString", "unterminated string, got EOF."
End If

Dim strTemp
Expand Down Expand Up @@ -281,7 +281,7 @@ Function ParseString(strRaw)
ParseString = ParseString & Right(strTemp, 1)
Else
Err.Raise vbObjectError, _
"ParseString", "Unterminated string, got EOF."
"ParseString", "unterminated string, got EOF."
End If
End If
End Function
9 changes: 7 additions & 2 deletions impls/vbs/step1_read_print.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step2_eval.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step3_env.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step4_if_fn_do.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step5_tco.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step6_file.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step7_quote.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
9 changes: 7 additions & 2 deletions impls/vbs/step8_macros.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,15 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
On Error Goto 0
Wend
Expand Down
12 changes: 9 additions & 3 deletions impls/vbs/step9_try.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,21 @@ Sub REPL()
If Err.Number <> 0 Then WScript.Quit 0
On Error Goto 0

Dim strRes
On Error Resume Next
WScript.Echo REP(strCode)
strRes = REP(strCode)
If strRes <> "" Then
WScript.Echo strRes
End If
If Err.Number <> 0 Then
If Err.Source = "MThrow" Then
WScript.StdErr.WriteLine Err.Source + ": " + _
'WScript.StdErr.WriteLine Err.Source + ": " + _
WScript.StdErr.WriteLine "Exception: " + _
PrintMalType(objExceptions.Item(Err.Description), True)
objExceptions.Remove Err.Description
Else
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
End If
On Error Goto 0
Expand Down
6 changes: 4 additions & 2 deletions impls/vbs/stepA_mal.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,13 @@ Sub REPL()
End If
If Err.Number <> 0 Then
If Err.Source = "MThrow" Then
WScript.StdErr.WriteLine Err.Source + ": " + _
'WScript.StdErr.WriteLine Err.Source + ": " + _
WScript.StdErr.WriteLine "Exception: " + _
PrintMalType(objExceptions.Item(Err.Description), True)
objExceptions.Remove Err.Description
Else
WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
'WScript.StdErr.WriteLine Err.Source + ": " + Err.Description
WScript.StdErr.WriteLine "Exception: " + Err.Description
End If
End If
On Error Goto 0
Expand Down

0 comments on commit 51cd399

Please sign in to comment.