Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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.");
}
}
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.");
}
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.");
}
}
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.");
}
}
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.");
}
}
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.");
}
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.");
}
}
private async _Handle_reject(reason: string): Promise
{
this.state_ = SharedWorkerConnector.State.CLOSING;
this.connector_!.second(new RuntimeError(reason));
await this._Handle_close();
}