Google

Go to the first, previous, next, last section, table of contents.


error

error(message)
:: プログラム中で強制的にエラーを発生させる.
message
文字列
  • 一般に, 引数の間違いなど, 続行不可能なエラーが組み込み函数において 発生した時, トップレベルに戻る前に, 可能ならばそのエラーの時点で デバッグモードに入る. error() は, ユーザ函数の内部でこの 動作と同様の動作を行わせるための函数である.
  • 引数は, error() が呼び出される際に表示されるメッセージで, 文字列である.
  • ユーザ函数において, 変数をチェックして, あり得ない値の場合に error() を呼び出すようにしておけば, その時点で自動的にデバッグモードに入れる.
% cat mod3
def mod3(A) {
        if ( type(A) >= 2 )
                error("invalid argument");
        else
                return A % 3;
}
end$
% asir
[0] load("mod3");
1
[3] mod3(5);
2
[4] mod3(x);
invalid argument
stopped in mod3 at line 3 in file "./mod3"
3                       error("invalid argument");
(debug) print A
A = x
(debug) quit
return to toplevel
[4] 
参照
section debug.


Go to the first, previous, next, last section, table of contents.