Skip to content

Error message - Exception has been thrown by the target of an invocation. #138

@iisfaq

Description

@iisfaq

I was just testing your cool parser and came across the following

"Chris"[35]

This returns Exception has been thrown by the target of an invocation. - not a very friendly message.

I tracked it down to the following line


 2926                        else if (itemProperties?.Length > 0)
*2927                            return itemProperties[0].GetValue(left, oIndexingArgs.Cast<object>().ToArray()); 
 2928                        else

I changed the code to this

                            try
                            {
                                return itemProperties[0].GetValue(left, oIndexingArgs.Cast<object>().ToArray());
                            }
                            catch(Exception ex)
                            {
                                throw new Exception($"Invalid index speciifed '{string.Join(",",oIndexingArgs.Cast<object>().ToArray())}' for '{left}'");
                            }

This results in something like this

Invalid index specified '35' for 'Chris'

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions