◢███◤      ◢██◤                            ◢██◤                            
     ◢██◤       ◢██◤                            ◢██◤                             
    ◢██◤       ◢██◤                            ◢██◤                              
   ◢██◤       ◢██◤                            ◢██◤                               
  ◢██◤       ◢██◤                            ◢██◤                                
◢███◤       ◢██◤                            ◢██◤                          ◥██◣   
◥███       ◢█████◣    ◢████████◤ ◢███████◤ ◢██◤ ◢██◤                 ◢██◤   ██◣  
 ███      ◢███████◣        ◢██◤ ◢██◤ ◢██◤ ◢███████◤                 ◢██◤    ███  
 ███     ◢██◤  ◢██◤ ◢████████◤ ◢██◤      ◢█████◣                   ◢██◤     ███  
 ███    ◢██◤  ◢██◤ ◢██◤  ███◤ ◢██◤ ◢██◤ ◢██◤◥███◣                 ◢██◤      ███  
 ◥██   ◢██◤  ◢██◤ ◢████████◤ ◢███████◤ ◢██◤  ◥███◣               ◢██◤       ███◣ 
  ◥██◣                                                          ◢██◤       ◢███◤ 
                                 ◢███◤ ◢███◤ ◢██◤  ◢██◤ ◢█████████◤       ◢██◤   
                                ◢█████████◤ ◢██◤  ◢██◤ ◢██◤  ████◤       ◢██◤    
                               ◢██◤◢█◤◢██◤ ◢██◤  ◢██◤ ◢██◤   ███◤       ◢██◤     
                              ◢██◤   ◢██◤ ◢████████◤ ◢█████████◤       ◢██◤      
                             ◢██◤   ◢██◤ ◢████████◤ ◢█████████◤      ◢███◤       

0003
Common Script Errors and Causes
There are a few common script errors that are almost always caused by the same general error. This post tries to list as many of them as we could think of. Add more in comments, and I'll copy into the main body. `AUPLOAD ERRORS` {`Nretval`:`V"PARSE ERROR ``Cyour``V.``Lscript``V: Error: Line NUM: Unexpected end of input"`,`Nsuccess`:`Vfalse`} Where NUM is a number significantly larger than your script is long: almost always a missing }, ], or ) (in roughly that order of likeliness) {`Nretval`:`V"PARSE ERROR ``Cyour``V.``Lscript``V: Error: Line NUM: Unexpected token ILLEGAL"`,`Nsuccess`:`Vfalse`} Almost always an incorrect usage of a preprocessor expansion. Common examples: #fs.`Cfoo`.`Lbar` `l// no parens` #fs.`Cfoo`.`Lbar` () `l// space before parens` #fmcl `l// should be in caps` #DB.F() `l// should be in lower case` Note: The line number here is almost always close to accurate. Look above or below the number indicated by a few lines. {`Nretval`:`V"PARSE ERROR ``Cyour``V.``Lscript``V (line 1): code must be wrapped in a function (must start with 'function (context, args){'"`,`Nsuccess`:`Vfalse`} {`Nretval`:`V"PARSE ERROR ``Cyour``V.``Lscript``V (line NUM): code must be wrapped in a function (must end with '}')"`,`Nsuccess`:`Vfalse`} Usually caused by a comment above (first case) or after (second case) your main function. These comments must be inside the function. `A>>#up something.js` Could not find the script source file. Don't specify .js, it is added automatically. `ARUNTIME ERRORS` `D:::TRUST COMMUNICATION:::` TypeError: Cannot read property 'foo' of null Where 'foo' is an argument you access in the script (like `Cargs.foo`). Almost always this is caused by accessing arguments (like `Cargs.foo`) in a script, but calling the script without arguments (i.e. `Cfoo`.`Lbar` not `Cfoo`.`Lbar`{}). Relatively easy fix: add "`Cargs=args||{}`" to the top of your script, just inside the function `D:::TRUST COMMUNICATION:::` TypeError: Cannot read property '1' of null Where 1 is almost always 1, but maybe 2 or 3. This is almost always caused by doing `Cstr.match(someRegex)[1]`, but the regex doesn't match the string at all. I usually do something like `C(str.match(someRegex)||[,"FAIL"])[1]`. `D:::TRUST COMMUNICATION:::` TypeError: someVar.split is not a function `D:::TRUST COMMUNICATION:::` TypeError: someVar.match is not a function (etc) You are expecting a string (or array or object) but had something else. Common causes: t1 corps returning an object when shifting, and you expected a string and blindly tried to call string methods on it; certain parts of corps returning arrays when you think they return strings. Easiest fix: if you assume a type after calling an external script, check the type (with typeof) to make sure, and raise a better error if the type isn't what you want. For example, if you expect someVar to be a string, consider adding `Cif(typeof someVar!="string")return someVar` `l// someVar probably has an error message in it so may as well show it to the user`
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -