@@ -10,7 +10,7 @@ use crate::bindings::{
1010use bevy:: {
1111 ecs:: component:: ComponentId ,
1212 prelude:: Entity ,
13- reflect:: { func :: FunctionError , PartialReflect , Reflect } ,
13+ reflect:: { PartialReflect , Reflect } ,
1414} ;
1515use std:: {
1616 any:: TypeId ,
@@ -481,13 +481,6 @@ impl InteropError {
481481 } ) )
482482 }
483483
484- /// Thrown when the error happens after a function call, and an error is thrown by bevy.
485- ///
486- /// I.e. mismatch in args, or invalid number of arguments
487- pub fn function_call_error ( inner : FunctionError ) -> Self {
488- Self ( Arc :: new ( InteropErrorInner :: FunctionCallError { inner } ) )
489- }
490-
491484 /// Thrown when an error happens during argument conversion in a function call
492485 pub fn function_arg_conversion_error ( argument : String , error : InteropError ) -> Self {
493486 Self ( Arc :: new ( InteropErrorInner :: FunctionArgConversionError {
@@ -555,6 +548,14 @@ impl InteropError {
555548 variant_name : variant_name. to_string ( ) ,
556549 } ) )
557550 }
551+
552+ /// Thrown when the number of arguments in a function call does not match.
553+ pub fn argument_count_mismatch ( expected : usize , got : usize ) -> Self {
554+ Self ( Arc :: new ( InteropErrorInner :: ArgumentCountMismatch {
555+ expected,
556+ got,
557+ } ) )
558+ }
558559}
559560
560561/// For errors to do with reflection, type conversions or other interop issues
@@ -684,11 +685,6 @@ pub(crate) enum InteropErrorInner {
684685 /// The component that was invalid
685686 component_id : ComponentId ,
686687 } ,
687- /// Thrown when an error happens in a function call
688- FunctionCallError {
689- /// The inner error that occurred
690- inner : FunctionError ,
691- } ,
692688 /// Thrown when an error happens during argument conversion in a function call
693689 MissingFunctionError {
694690 /// The type that the function was attempted to be called on
@@ -739,6 +735,8 @@ pub(crate) enum InteropErrorInner {
739735 type_id : TypeId ,
740736 variant_name : String ,
741737 } ,
738+ /// Thrown when the number of arguments in a function call does not match.
739+ ArgumentCountMismatch { expected : usize , got : usize } ,
742740}
743741
744742/// For test purposes
@@ -879,10 +877,6 @@ impl PartialEq for InteropErrorInner {
879877 InteropErrorInner :: InvalidComponent { component_id : a } ,
880878 InteropErrorInner :: InvalidComponent { component_id : b } ,
881879 ) => a == b,
882- (
883- InteropErrorInner :: FunctionCallError { inner : a } ,
884- InteropErrorInner :: FunctionCallError { inner : b } ,
885- ) => a == b,
886880 (
887881 InteropErrorInner :: MissingFunctionError {
888882 on : a,
@@ -947,6 +941,16 @@ impl PartialEq for InteropErrorInner {
947941 variant_name : d,
948942 } ,
949943 ) => a == c && b == d,
944+ (
945+ InteropErrorInner :: ArgumentCountMismatch {
946+ expected : a,
947+ got : b,
948+ } ,
949+ InteropErrorInner :: ArgumentCountMismatch {
950+ expected : c,
951+ got : d,
952+ } ,
953+ ) => a == c && b == d,
950954 _ => false ,
951955 }
952956 }
@@ -1084,12 +1088,6 @@ macro_rules! function_arg_conversion_error {
10841088 } ;
10851089}
10861090
1087- macro_rules! function_call_error {
1088- ( $inner: expr) => {
1089- format!( "Error in function call: {}" , $inner)
1090- } ;
1091- }
1092-
10931091macro_rules! better_conversion_exists {
10941092 ( $context: expr) => {
10951093 format!( "Unfinished conversion in context of: {}. A better conversion exists but caller didn't handle the case." , $context)
@@ -1248,9 +1246,6 @@ impl DisplayWithWorld for InteropErrorInner {
12481246 InteropErrorInner :: FunctionArgConversionError { argument, error } => {
12491247 function_arg_conversion_error ! ( argument, error. display_with_world( world) )
12501248 } ,
1251- InteropErrorInner :: FunctionCallError { inner } => {
1252- function_call_error ! ( inner)
1253- } ,
12541249 InteropErrorInner :: BetterConversionExists { context } => {
12551250 better_conversion_exists ! ( context)
12561251 } ,
@@ -1277,6 +1272,12 @@ impl DisplayWithWorld for InteropErrorInner {
12771272 type_id. display_with_world( world)
12781273 )
12791274 } ,
1275+ InteropErrorInner :: ArgumentCountMismatch { expected, got } => {
1276+ format ! (
1277+ "Argument count mismatch, expected: {}, got: {}" ,
1278+ expected, got
1279+ )
1280+ } ,
12801281 }
12811282 }
12821283
@@ -1387,9 +1388,6 @@ impl DisplayWithWorld for InteropErrorInner {
13871388 InteropErrorInner :: FunctionArgConversionError { argument, error } => {
13881389 function_arg_conversion_error ! ( argument, error. display_without_world( ) )
13891390 } ,
1390- InteropErrorInner :: FunctionCallError { inner } => {
1391- function_call_error ! ( inner)
1392- } ,
13931391 InteropErrorInner :: BetterConversionExists { context } => {
13941392 better_conversion_exists ! ( context)
13951393 } ,
@@ -1416,6 +1414,12 @@ impl DisplayWithWorld for InteropErrorInner {
14161414 type_id. display_without_world( )
14171415 )
14181416 } ,
1417+ InteropErrorInner :: ArgumentCountMismatch { expected, got } => {
1418+ format ! (
1419+ "Argument count mismatch, expected: {}, got: {}" ,
1420+ expected, got
1421+ )
1422+ } ,
14191423 }
14201424 }
14211425}
0 commit comments