How to use the tstl/exception.RuntimeError function in tstl

To help you get started, we’ve selected a few tstl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github samchon / tgrid / src / protocols / internal / IAcceptor.ts View on Github external
export function inspect(state: State): Error | null
    {
        // NO ERROR
        if (state === State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (state === State.NONE)
            return new DomainError("Not accepted yet.");
        else if (state === State.ACCEPTING)
            return new DomainError("On accepting; wait for a sec.");
        else if (state === State.REJECTING || State.CLOSING)
            return new RuntimeError("The connection is on closing.");
        else if (state === State.CLOSED)
            return new RuntimeError("The connection has been closed.");

        // UNKNOWN ERROR, IT MAY NOT OCCURED
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
}
github samchon / tgrid / src / protocols / workers / WorkerServer.ts View on Github external
if (this.state_ === WorkerServer.State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (this.state_ === WorkerServer.State.NONE)
            return new DomainError("Server is not opened yet.");
        else if (this.state_ === WorkerServer.State.OPENING)
            return new DomainError("Server is on opening; wait for a sec.");
        else if (this.state_ === WorkerServer.State.CLOSING)
            return new RuntimeError("Server is on closing.");

        // MAY NOT BE OCCURED
        else if (this.state_ === WorkerServer.State.CLOSED)
            return new RuntimeError("The server has been closed.");
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
github samchon / tgrid / src / protocols / internal / IConnector.ts View on Github external
if (state === State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (state === State.NONE)
            return new DomainError("Connect first.");
        else if (state === State.CONNECTING)
            return new DomainError("On connecting; wait for a sec.");
        else if (state === State.CLOSING)
            return new RuntimeError("The connection is on closing.");
        else if (state === State.CLOSED)
            return new RuntimeError("The connection has been closed.");

        // UNKNOWN ERROR, IT MAY NOT OCCURED
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
}
github samchon / tgrid / src / protocols / internal / IConnector.ts View on Github external
export function inspect(state: State): Error | null
    {
        // NO ERROR
        if (state === State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (state === State.NONE)
            return new DomainError("Connect first.");
        else if (state === State.CONNECTING)
            return new DomainError("On connecting; wait for a sec.");
        else if (state === State.CLOSING)
            return new RuntimeError("The connection is on closing.");
        else if (state === State.CLOSED)
            return new RuntimeError("The connection has been closed.");

        // UNKNOWN ERROR, IT MAY NOT OCCURED
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
}
github samchon / tgrid / src / protocols / internal / IAcceptor.ts View on Github external
export function inspect(state: State): Error | null
    {
        // NO ERROR
        if (state === State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (state === State.NONE)
            return new DomainError("Not accepted yet.");
        else if (state === State.ACCEPTING)
            return new DomainError("On accepting; wait for a sec.");
        else if (state === State.REJECTING || State.CLOSING)
            return new RuntimeError("The connection is on closing.");
        else if (state === State.CLOSED)
            return new RuntimeError("The connection has been closed.");

        // UNKNOWN ERROR, IT MAY NOT OCCURED
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
}
github samchon / tgrid / src / protocols / workers / WorkerServer.ts View on Github external
protected inspectReady(): Error | null
    {
        // NO ERROR
        if (this.state_ === WorkerServer.State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (this.state_ === WorkerServer.State.NONE)
            return new DomainError("Server is not opened yet.");
        else if (this.state_ === WorkerServer.State.OPENING)
            return new DomainError("Server is on opening; wait for a sec.");
        else if (this.state_ === WorkerServer.State.CLOSING)
            return new RuntimeError("Server is on closing.");

        // MAY NOT BE OCCURED
        else if (this.state_ === WorkerServer.State.CLOSED)
            return new RuntimeError("The server has been closed.");
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
github samchon / tgrid / src / protocols / internal / IConnector.ts View on Github external
export function inspect(state: State): Error | null
    {
        // NO ERROR
        if (state === State.OPEN)
            return null;

        // ERROR, ONE OF THEM
        else if (state === State.NONE)
            return new DomainError("Connect first.");
        else if (state === State.CONNECTING)
            return new DomainError("On connecting; wait for a sec.");
        else if (state === State.CLOSING)
            return new RuntimeError("The connection is on closing.");
        else if (state === State.CLOSED)
            return new RuntimeError("The connection has been closed.");

        // UNKNOWN ERROR, IT MAY NOT OCCURED
        else
            return new RuntimeError("Unknown error, but not connected.");
    }
}
github samchon / tgrid / src / protocols / workers / SharedWorkerConnector.ts View on Github external
private async _Handle_reject(reason: string): Promise
    {
        this.state_ = SharedWorkerConnector.State.CLOSING;
        this.connector_!.second(new RuntimeError(reason));

        await this._Handle_close();
    }