mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
fix up inconsistent error types
This commit is contained in:
@@ -9,19 +9,19 @@ var threadChan = make(chan bool)
|
||||
|
||||
func ArThread(args ...any) (any, ArErr) {
|
||||
if len(args) != 1 {
|
||||
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 1, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||
return nil, ArErr{TYPE: "Type Error", message: "Invalid number of arguments, expected 1, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||
}
|
||||
var tocall any
|
||||
switch x := args[0].(type) {
|
||||
case anymap:
|
||||
if _, ok := x["__call__"]; !ok {
|
||||
return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}
|
||||
return nil, ArErr{TYPE: "Type Error", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}
|
||||
}
|
||||
tocall = x["__call__"]
|
||||
case builtinFunc, Callable:
|
||||
tocall = x
|
||||
default:
|
||||
return nil, ArErr{TYPE: "TypeError", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}
|
||||
return nil, ArErr{TYPE: "Type Error", message: "Cannot call thread with a '" + typeof(args[0]) + "'", EXISTS: true}
|
||||
}
|
||||
var resp any
|
||||
var err ArErr
|
||||
@@ -35,7 +35,7 @@ func ArThread(args ...any) (any, ArErr) {
|
||||
return nil, ArErr{TYPE: "Runtime Error", message: "Cannot start a thread twice", EXISTS: true}
|
||||
}
|
||||
if len(args) != 0 {
|
||||
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 0, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||
return nil, ArErr{TYPE: "Type Error", message: "Invalid number of arguments, expected 0, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||
}
|
||||
hasrun = true
|
||||
threadCount++
|
||||
@@ -56,7 +56,7 @@ func ArThread(args ...any) (any, ArErr) {
|
||||
return nil, ArErr{TYPE: "Runtime Error", message: "Cannot join a thread twice", EXISTS: true}
|
||||
}
|
||||
if len(args) != 0 {
|
||||
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 0, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||
return nil, ArErr{TYPE: "Type Error", message: "Invalid number of arguments, expected 0, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||
}
|
||||
joined = true
|
||||
<-wg
|
||||
|
||||
Reference in New Issue
Block a user