User Tools

Site Tools


tutorial:command_exceptions

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Last revisionBoth sides next revision
tutorial:command_exceptions [2023/11/18 11:38] solidblocktutorial:command_exceptions [2024/04/15 06:35] solidblock
Line 5: Line 5:
 There are two type of command exceptions: There are two type of command exceptions:
   * **''CommandSyntaxException''**: provided by Brigadier. It should have an exception type, and created through ''create(...)'' or ''createWithContext(...)''. It does not belong to ''RuntimeException'', so when thrown, it must be caught properly, or added in the method signature.   * **''CommandSyntaxException''**: provided by Brigadier. It should have an exception type, and created through ''create(...)'' or ''createWithContext(...)''. It does not belong to ''RuntimeException'', so when thrown, it must be caught properly, or added in the method signature.
-  * **''<yarn class_2164>''**: provided in Minecraft, and used in less cases. It belongs to ''RuntimeException''. You can directly create it with a ''Text'' as parameter.+  * **''<yarn class_2164>'' (removed since 1.20.3)**: provided in Minecraft, and used in less cases. It belongs to ''RuntimeException''. You can directly create it with a ''Text'' as parameter.
  
 The two main types of ''CommandSyntaxException'' are dynamic and simple exception types, of which you can call ''create()'' to create the exception to throw it. These exceptions also allow you to specify the context in which the exception was thrown using ''createWithContext(ImmutableStringReader)'', which builds the error message to point to where on the inputted command line the error occured. The two main types of ''CommandSyntaxException'' are dynamic and simple exception types, of which you can call ''create()'' to create the exception to throw it. These exceptions also allow you to specify the context in which the exception was thrown using ''createWithContext(ImmutableStringReader)'', which builds the error message to point to where on the inputted command line the error occured.
Line 25: Line 25:
     }));     }));
 </code> </code>
 +:!: ''CommandException'' is removed since 1.20.3.
  
 ===== Using CommandSyntaxException ===== ===== Using CommandSyntaxException =====
tutorial/command_exceptions.txt · Last modified: 2024/04/15 06:43 by solidblock