Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.1 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Scilab > Error handling > error

error

エラーメッセージ

呼出し手順

error(message)
error(message, n)
error(n, message)

引数

message

文字列または文字列のベクトル. 表示されるエラーメッセージ.

n

整数. エラーメッセージの番号

説明

error 関数によりエラーメッセージを発行でき, エラーを処理できます. デフォルトで error は実行を停止し, プロンプトレベルに復帰します. このデフォルト動作は,errcatch または execstr(…,'errcatch') 関数により変更できます.

error(message)messageの文字列を 出力します. エラーメッセージの番号は 10000 となります.

error(message,n)messageの文字列を出力します. エラーメッセージの番号はnで指定されます.

エラーメッセージのリストおよび対応するエラー番号については error_table を参照ください.

function test(a)
    if argn(2)~=1
        msg = gettext("%s: Wrong number of input arguments: %d expected.\n")
        error(msprintf(msg, "test", 1))
    end
endfunction
function myfun()
    a = 1;
    test()
endfunction

// ----------

error(['A multi line' 'error message'])
error(500, 'Error: my error message')
[m, n] = lasterror()

test()
myfun()
--> error(['A multi line' 'error message'])

A multi line
error message

--> error(500, 'Error: my error message')

Error: my error message

--> [m, n] = lasterror()
 n  =
   500.
 m  =
 Error: my error message


--> test()
関数の     4 行目 test

test: 入力引数の数が間違っています: 1 個の引数を指定してください.
--> myfun()
関数の     4 行目 test
関数の     3 行目 myfun

test: 入力引数の数が間違っています: 1 個の引数を指定してください.

参照

  • lasterror — 直近に記録されたエラーメッセージを取得
  • error_table — list of main standard errors messages
  • gettext — indexes or/and translates some indexed english messages
  • warning — 警告メッセージ
  • try — try-catch 制御命令のtryブロックを開始
  • execstr — 文字列中のScilabコードを実行
  • where — カレントの命令の呼び出しツリーを得る

履歴

バージョン記述
5.0.0 error(n, message) syntax introduced.
5.4.0 error 関数は入力引数として文字列ベクトルを受け付けます.
6.0.0 The error(n) and error(n, pos) syntaxes are no longer supported: Providing an explicit error message is now mandatory. There is no longer any absolute error identifier.
Report an issue
<< errclear Error handling error_table >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Jan 03 14:37:44 CET 2022