charlang/example/checkErr.char
Copy
// checkErr: check if the object is error or error string, if is, exit the program with output, usage: checkErr(result, "-format=Failed to process: %v\n"), the default format is "Error: %v\n" result := fromJson(`{"abc": 1 23}`) checkErr(result, "-format=" + spr("[%v] %v err: %%v\n", getNowStr(), undefined)) // this line will not run, since checkErr will stop the script while result is error or TXERROR string pl("done 3")