summaryrefslogtreecommitdiff
path: root/operators.c
diff options
context:
space:
mode:
authorPeter Mikkelsen <peter@pmikkelsen.com>2022-02-22 21:25:36 +0000
committerPeter Mikkelsen <peter@pmikkelsen.com>2022-02-22 21:25:36 +0000
commit40af1deff9db7b86532db6957ebdbc0aaff38db1 (patch)
treecb417113744f26a015d36ee6732746c4e808e700 /operators.c
parentae6471f1c94f51df540d95edc09c7749002f44e8 (diff)
Make errors more like dyalog:
* Use the same error numbers * Rename ⎕THROW to ⎕SIGNAL * Implement ⎕EN to inspect the last error code * Implement ⎕EM to get a message from an error code
Diffstat (limited to 'operators.c')
-rw-r--r--operators.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/operators.c b/operators.c
index 7a7f12d..7e2520c 100644
--- a/operators.c
+++ b/operators.c
@@ -86,7 +86,7 @@ Array *
opKey(Datum *lefto, Array *left, Array *right)
{
if(lefto->tag != FunctionTag)
- throwerror(nil, EType);
+ throwerror(nil, ESyntax);
if(left)
return rundfn(L"↑⍵∘(⍶{⍵⍶⍺⌷⍨⊂⍸⍹≡¨⍵}⍺)¨⊂¨∪⍺", lefto, nil, left, right);
else
@@ -97,7 +97,7 @@ Array *
opSpawn(Datum *lefto, Array *left, Array *right)
{
if(lefto->tag != FunctionTag)
- throwerror(L"Can only spawn functions", EType);
+ throwerror(L"Can only spawn functions", ESyntax);
int id = spawnthread(lefto->func, left, right);
return mkscalarint(id);
}
@@ -108,7 +108,7 @@ opOuterProduct(Datum *lefto, Array *left, Array *right)
if(left == nil)
throwerror(L"f⌾ expected a left argument", ESyntax);
if(lefto->tag != FunctionTag)
- throwerror(nil, EType);
+ throwerror(nil, ESyntax);
int i;
int rank = GetRank(left) + GetRank(right);
@@ -156,9 +156,9 @@ Array *
opReceive(Datum *lefto, Array *left, Array *right)
{
if(lefto->tag != FunctionTag)
- throwerror(nil, EType);
+ throwerror(nil, ESyntax);
if(GetType(right) != AtypeInt)
- throwerror(nil, EType);
+ throwerror(nil, EDomain);
if(GetSize(right) != 1)
throwerror(nil, ELength);
USED(left);
@@ -171,7 +171,7 @@ opPower(Datum *lefto, Datum *righto, Array *left, Array *right)
{
Rune *code = nil;
if(lefto->tag != FunctionTag)
- throwerror(nil, EType);
+ throwerror(nil, ESyntax);
if(righto->tag == FunctionTag){
if(left)
code = L"next←⍺⍶⍵ ⋄ next⍹⍵:⍵ ⋄ ⍺∇next";
@@ -206,7 +206,7 @@ opInnerProduct(Datum *lefto, Datum *righto, Array *left, Array *right)
if(left == nil)
throwerror(L"f.g expected a left argument", ESyntax);
if(lefto->tag != FunctionTag || righto->tag != FunctionTag)
- throwerror(nil, EType);
+ throwerror(nil, ESyntax);
if(GetRank(left) > 0 && GetRank(right) > 0 && left->shape[GetRank(left)-1] != right->shape[0])
throwerror(nil, ELength);
@@ -251,7 +251,7 @@ opAtop(Datum *lefto, Datum *righto, Array *left, Array *right)
if(GetRank(ranks) > 1)
throwerror(nil, ERank);
if(GetType(ranks) != AtypeInt)
- throwerror(nil, EType);
+ throwerror(nil, EDomain);
if(GetSize(ranks) < 1 || GetSize(ranks) > 3)
throwerror(nil, ELength);
int p,q,r;