err.fs 6.63 KB
Newer Older
bernd's avatar
bernd committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
\ Copyright (C) 2010-2014   Bernd Paysan

\ This program is free software: you can redistribute it and/or modify
\ it under the terms of the GNU Affero General Public License as published by
\ the Free Software Foundation, either version 3 of the License, or
\ (at your option) any later version.

\ This program is distributed in the hope that it will be useful,
\ but WITHOUT ANY WARRANTY; without even the implied warranty of
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
\ GNU Affero General Public License for more details.

\ You should have received a copy of the GNU Affero General Public License
\ along with this program.  If not, see <http://www.gnu.org/licenses/>.

\ defined exceptions

: throwcode ( addr u -- )  exception Create ,
19 20
    [: ( flag -- ) @ and throw ;] set-does>
    [: >body @ >r ]] IF [[ r> ]] literal throw THEN [[ ;] set-optimizer ;
bernd's avatar
bernd committed
21

22 23 24 25
\ make sure we start at user defined exeption
\ net2o exception codes should be system-independent
-$1000 next-exception !@

bernd's avatar
bernd committed
26 27 28 29
s" gap in file handles"          throwcode !!gap!!
s" invalid file id"              throwcode !!fileid!!
s" could not send"               throwcode !!send!!
s" wrong packet size"            throwcode !!size!!
30
s" map size too big"             throwcode !!mapsize!!
bernd's avatar
bernd committed
31
s" unimplemented net2o function" throwcode !!function!!
bernd's avatar
bernd committed
32
s" invalid net2o function"       throwcode !!invalid!!
bernd's avatar
bernd committed
33
s" too many commands"            throwcode !!commands!!
34
s" float does not fit"           throwcode !!floatfit!!
bernd's avatar
bernd committed
35
s" string does not fit"          throwcode !!stringfit!!
36
s" cmd does not fit"             throwcode !!cmdfit!!
bernd's avatar
bernd committed
37 38 39 40 41 42 43 44 45
s" ivs must be 64 bytes"         throwcode !!ivs!!
s" net2o timed out"              throwcode !!timeout!!
s" maximum nesting reached"      throwcode !!maxnest!!
s" nesting stack empty"          throwcode !!minnest!!
s" invalid nest"                 throwcode !!nest!!
s" invalid tmpnest"              throwcode !!tmpnest!!
s" cookie recieved twice"        throwcode !!double-cookie!!
s" code destination is 0"        throwcode !!no-dest!!
s" no IP addr"                   throwcode !!no-addr!!
46
s" Invalid file name"            throwcode !!filename!!
bernd's avatar
bernd committed
47 48 49 50 51
s" invalid packet destination"   throwcode !!inv-dest!!
s" unknown key"                  throwcode !!unknown-key!!
s" wrong key"                    throwcode !!wrong-key!!
s" no key file"                  throwcode !!nokey!!
s" invalid Ed25519 key"          throwcode !!no-ed-key!!
52
s" wrong key size"               throwcode !!keysize!!
53
s" no signature appended"        throwcode !!no-sig!!
bernd's avatar
bernd committed
54
s" future signature"             throwcode !!new-sig!!
55 56
s" expired signature"            throwcode !!old-sig!!
s" invalid signature"            throwcode !!inv-sig!!
Bernd Paysan's avatar
Bernd Paysan committed
57
s" failed to open message"       throwcode !!msg-locked!!
bernd's avatar
bernd committed
58
s" no temporary key"             throwcode !!no-tmpkey!!
59
s" generic stack empty"          throwcode !!stack-empty!!
bernd's avatar
bernd committed
60 61
s" String stack full"            throwcode !!string-full!!
s" String stack empty"           throwcode !!string-empty!!
62 63
s" Object stack full"            throwcode !!object-full!!
s" Object stack empty"           throwcode !!object-empty!!
bernd's avatar
bernd committed
64 65 66 67
s" Unknown crypto function"      throwcode !!unknown-crypt!!
s" Wrong revocation secret"      throwcode !!not-my-revsk!!
s" krypto mem request too big"   throwcode !!kr-size!!
s" secret storage size wrong"    throwcode !!sec-size!!
68
s" net2o id not found"           throwcode !!host-notfound!!
bernd's avatar
bernd committed
69
s" too many revokes chained"     throwcode !!maxlookup!!
70
s" file class denied"            throwcode !!fileclass!!
71
s" no free termservers"          throwcode !!no-termserver!!
bernd's avatar
bernd committed
72 73
s" decryption failed"            throwcode !!no-decrypt!!
s" no data"                      throwcode !!no-data!!
bernd's avatar
bernd committed
74
s" invalid command order"        throwcode !!inv-order!!
75
s" nick not found"               throwcode !!no-nick!!
bernd's avatar
bernd committed
76
s" passphrases don't match"      throwcode !!passphrase-unmatch!!
bernd's avatar
bernd committed
77
s" data needs to be signed"      throwcode !!unsigned!!
78
s" data needs to be unsigned"    throwcode !!signed!!
bernd's avatar
bernd committed
79
s" invalid DHT key"              throwcode !!no-dht-key!!
80
s" dht exhausted - this should not happen" throwcode !!dht-full!!
81 82 83 84
s" 4cc wants 3 characters"       throwcode !!4cc!!
s" key setup already done"       throwcode !!doublekey!!
s" host or id not found"         throwcode !!no-address!!
s" hash mismatch"                throwcode !!wrong-hash!!
85
s" connection refused"           throwcode !!connect-perm!!
bernd's avatar
bernd committed
86 87 88 89
s" DHT permission denied"        throwcode !!dht-perm!!
s" MSG permission denied"        throwcode !!msg-perm!!
s" file read permission denied"  throwcode !!filerd-perm!!
s" file write permission denied" throwcode !!filewr-perm!!
bernd's avatar
bernd committed
90
s" file access by name denied"   throwcode !!filename-perm!!
91
s" file access by hash denied"   throwcode !!filehash-perm!!
92 93 94 95
s" socket access denied"         throwcode !!socket-perm!!
s" terminal access denied"       throwcode !!terminal-perm!!
s" termserver access denied"     throwcode !!termserver-perm!!
s" sync access denied"           throwcode !!sync-perm!!
96 97
s" patch size exceeds limit"     throwcode !!patch-limit!!
s" patch size wrong"             throwcode !!patch-size!!
bernd's avatar
bernd committed
98
s" insufficiend randomness"      throwcode !!insuff-rnd!!
bernd's avatar
bernd committed
99
s" no key opened"                throwcode !!no-key-open!!
bernd's avatar
bernd committed
100
s" unknwon protocol"             throwcode !!unknown-protocol!!
101
s" unsaulted random number"      throwcode !!no-salt!!
bernd's avatar
bernd committed
102
s" unhealthy RNG state"          throwcode !!bad-rng!!
103
s" repeated tmpkey"              throwcode !!repeated-tmpkey!!
bernd's avatar
bernd committed
104
s" Unknown group"                throwcode !!no-group!!
bernd's avatar
bernd committed
105
s" Challenge failed"             throwcode !!challenge!!
106
s" Stack should always be empty" throwcode !!depth!!
Bernd Paysan's avatar
Bernd Paysan committed
107
s" hashed object not read in"    throwcode !!dvcs-hash!!
Bernd Paysan's avatar
Bernd Paysan committed
108 109
s" Value has no unit"            throwcode !!no-unit!!
s" Token/Coin doesn't exist"     throwcode !!no-coin!!
110
s" not a wallet"                 throwcode !!wallet!!
Bernd Paysan's avatar
Bernd Paysan committed
111 112
s" no group name"                throwcode !!no-group-name!!
s" no base85 digit"              throwcode !!no-85-digit!!
Bernd Paysan's avatar
Bernd Paysan committed
113
s" Vault auth block error"       throwcode !!vault-auth!!
114
s" Deprecated command"           throwcode !!deprecated!!
115
s" Connection successful"        throwcode !!connected!!
116 117
s" Invalid index"                throwcode !!inv-index!!
s" hash not last pk's state"     throwcode !!squid-hash!!
118 119 120 121 122
s" Double transaction!"          throwcode !!double-transaction!!
s" Insufficient asset!"          throwcode !!insufficient-asset!!
s" Transaction not balanced!"    throwcode !!not-balanced!!
s" Sink already cleared!"        throwcode !!sink-cleared!!
s" Sink not cleared!"            throwcode !!not-sunk!!
123
s" Invalid permission!"          throwcode !!inv-perm!!
124

125 126
next-exception !

bernd's avatar
bernd committed
127 128
: sig-enum>throw ( enum -- throwcode )
    [ ' !!inv-sig!! >body @ 1- ]L swap - ;
129
: !!sig!! ( n -- )
Bernd Paysan's avatar
Bernd Paysan committed
130
    ?dup-IF  sig-enum>throw throw  THEN ;