.. highlightlang:: us .. _error_create: error_create ============ .. index:: error_create .. us.tag error_create NOTREADYENGLISH New410 :ref:`error_create` creates an error object. .. function:: e = error_create(domain, code, message) .. us.return **Return Value** *e* is an error object. .. us.params **Parameters** .. uparam:: domain *domain* is the group the error belongs to e.g. "file-error". .. uparam:: code *code* is the error number. The error number is only valid within a group. .. uparam:: message *message* is the error message (string). .. us.comment **Comment** The 3 variables of the error object can be accessed using period (.) - the object member-selection expression e.g. ``e.message = "file not found";``. .. us.example **Example** :: def test() { o = obj_create(); e = o.load("d:/laksjdlksajd"); if (type(e) == "error") { MessageBoxError("%s\n\nError-No.: %d\n%s", e.domain, e.code, e.message); return e; } return 0; } Use of :ref:`error_create` in a UniScript function: :: def test(a, b) { if (argsin() != 2) { return error_create("test-error", 1, "no of args must be 2"); } return a+b; } The user of test() can use the return value to check if an error occurred: :: res = test(1); if (type(res) == "error") { MessageBox(res.message); ... } ... .. seealso:: :ref:`overview-programming`, :ref:`type` :sub:`id-1376826`