import { LineResults } from "../LineResults" ; import { CommandNames } from "../Names/CommandNames" ; import { Command } from "./Command" ; import { CommandResult } from "./CommandResult" ; import { CommandMetadata } from "./Metadata/CommandMetadata" ; import { SingleParameter } from "./Metadata/Parameters/SingleParameter" ; import { addLineEnder } from "./Utilities" ; /**
 * Throws an exception.
 */ export class ThrowCommand extends Command { /**
     * Metadata on the command.
     */ private static metadata : CommandMetadata = new CommandMetadata ( CommandNames . Throw ) . withDescription ( "Throws an exception" ) . withParameters ( [ new SingleParameter ( "exception" , "Exception type to throw." , true ) , new SingleParameter ( "message" , "Message to attach to the exception." , true ) , ] ) ; returns public getMetadata ( ) { return ThrowCommand . metadata ; } param parameters returns public render ( parameters ) { let line = this . language . syntax . exceptions . throw ; line += " " + parameters [ 1 ] ; line += this . language . syntax . exceptions . throwMiddle ; line += parameters [ 2 ] ; const lines = [ new CommandResult ( line , 0 ) ] ; addLineEnder ( lines , this . language . syntax . exceptions . throwRight , 0 ) ; return new LineResults ( lines ) . withAddSemicolon ( true ) ; } }