Skip to main content

1E SDK

Instruction termination

Exit Codes

The Agent returns one of these codes to the Tachyon Server when it executes an instruction.

If a statement is successful it will return an Exit Code of 0 and a response which can be seen in the Content tab of the Explorer Responses page.

If a statement has no content, or produces an error, then no response is seen in the Content tab, however the Status tab of the Explorer Responses page shows a count for each Exit Code, and the ErrorData message where applicable.

If a statement exits early or produces an error then execution of the instruction terminates immediately with an Exit Code. Any changes made by the Agent are not rolled back.

Status

Code

ErrorData message

Meaning

Success

0

n/a

Success with content. This exit code is returned if the instruction is successful and has content.

V3.3 onwards lets you return 0 when a RETURN statement is used.

Success - no content

1

n/a

Success with no content. This exit code is returned if the instruction is successful but has no content.

This can occur if an EVALUATE statement is used. V3.3 onwards lets you return 1 when a RETURN , EVALUATE ,or NOCONTENT statement is used.

Error

2

Missing or invalid parameter 'xxx'.

The parameters do not match in quantity or type that the method expects. For example, a mandatory parameter name is missing, or its case-sensitive name is not correct.

Execution of SELECT failed.

A SELECT statement is not constructed correctly.

The Tachyon Agent language processor does not fully parse or check the syntax of the SELECT expression, but instead just passes it on (with variable name substitutions and string literal translations) to the SQLite API. Hence, if there is a syntax error, any line or column numbers in an error message are not precise.

Syntax error in instruction.

A parameter value is not correct.

An escape character may be required.

A statement may not be constructed correctly. For example, a ; terminator or other part of a statement is missing; or has superfluous characters.

<method specific errors>

Some examples:

Method

ErrorData

Notes

NativeServices.RunCommand

Command line returned exit code nnn.

Scripting.Run

'Language' returned exit code nnn:

'Language' is either Powershell or bash.

Missing 'xxx' provider.

A supported method or function is used but is unable to find the required provider. The provider file does not exist on the device.

<custom error message>

V3.3 onwards lets you return custom messages as defined in an ERROR statement.

Not implemented

3

No built-in function named 'xxx'.

The named function does not exist. This error is usually caused by a typo outside of a SELECT statement.

Unsupported module 'xxx'.

The module is not supported on this platform. This error can occur if:

  • the module is not enabled, for example Nomad methods are not available if Module.Nomad.Enabled=false

  • the module is not supported on this platform

  • the module library file does not exist on the device

  • the case-sensitive module name is not specified correctly

Unsupported method 'xxx'.

The method is not supported on this platform. This error can occur if:

  • the method is not supported on this platform

  • the case-sensitive module name is not specified correctly

Script language 'xxx' is not supported.

The language specified in Scripting.Run(Language: "xxx" ....) is not supported on this platform. This error can occur if:

  • the language is not supported on this platform (PowerShell is supported on Windows, bash is supported on Linux and MacOS)

  • the language name is not specified correctly. Language name is not case-sensitive.

<custom error message>

V3.3 onwards lets you return custom messages as defined in a NOTIMPLEMENTED statement.

Response too large

4

Early exit

The EVALUATE keyword allows an instruction to terminate early if the preceding statement did not yield any results.

From v3.3, SCALE supports the following additional termination keywords which can be used to exit an instruction, and return a corresponding Exit Code. These are most useful when used in conjunction with IF/ELSE/ENDIF construct but can be used anywhere within an instruction.

RETURN

RETURN allows you to exit out of an instruction early with a given set of results.

Syntax

@results = "some statement";
RETURN @results;

Ordinarily, the results of an instruction are based on the last statement to execute; RETURN allows you to do this at any point in an instruction. In contrast to EVALUATE (which means “break out of this instruction if the preceding statement returned no results), RETURN breaks unconditionally. With RETURN, you supply the @table whose value should become the results of the instruction.

The instruction exits successfully, with an exit code of 0 if the results have content, and 1 if they have no content.

Here’s an example:

@reg = NativeServices.RegistryGetValue(
            Hive:"HKLM",
            Subkey:"SOFTWARE\\MyVendor\\MyConfiguration",
            Name:"SecuritySetting");

// If the setting exists, return a message indicating we're secure
IF (@reg)
    @msg = SELECT "System already secure" AS Status;
    RETURN @msg;
ENDIF;

// Otherwise, take some action...
// ... and report that back. No need to use RETURN, because
// this is the last statement in the instruction.
SELECT "System was insecure, but is now secure" AS Status;
NOCONTENT

Syntax

//some statements
NOCONTENT;

NOCONTENT is an unconditional version of the EVALUATE keyword. Each causes an instruction to exit successfully, with an exit code of 1 meaning “Success, no content”, and do not return a message.

Here’s an example:

@users = Users.GetLoggedOnUsers();

// Return "success no content" if they are any logged in users
IF (@users)
    NOCONTENT;
ENDIF;

// ... otherwise do something which can only be done if no-one is logged on 
ERROR

Syntax

//some statements
ERROR "custom error message";

ERROR causes an instruction to terminate with exit code of 2 meaning “Error” and the specified custom error message. The error message must be supplied as a string literal, and cannot be a reference to a @table or any other kind of expression.

Here’s an example:

@svcs = OperatingSystem.GetServiceInfo();
@nomad = SELECT * FROM @svcs WHERE Name = "NomadBranch";

IF NOT (@nomad)
    ERROR "1E Nomad is not available";
ENDIF;

// Otherwise do some work with 1E Nomad...
NOTIMPLEMENTED

Syntax

//some statements
NOTIMPLEMENTED "custom error message";

NOTIMPLEMENTED causes an instruction to terminate with exit code of 3 meaning “Not implemented” and the specified custom error message. The error message must be supplied as a string literal, and cannot be a reference to a @table or any other kind of expression.

Here’s an example:

@dev = Device.GetSummary();
@win = SELECT * FROM @dev WHERE OperatingSystemType = "Windows";

IF NOT (@win)
    NOTIMPLEMENTED "This functionality is only available on Windows";
ENDIF;

// ... otherwise do something Windows-specific

(END OF PAGE)