Skip to content

Invalid static method invocations should give specific exception message #29

@adamedx

Description

@adamedx

Describe the bug
If you try to invoke a static method using |=> and pass a nonexistent method, you get a generic error message with almost no stack trace, certainly no information about the actual bug.

To Reproduce
Steps to reproduce the behavior:

scriptclass IHaveNoMethods { }
$::.IHaveNoMethods |=> idontexist
ScriptHalted
At C:\Users\adamed\src\autographps\.devmodule\scriptclass\0.20.1\src\scriptobject\dsl\MethodDsl.ps1:97 char:13
+             throw
+             ~~~~~
    + CategoryInfo          : OperationStopped: (:) [], RuntimeException
    + FullyQualifiedErrorId : ScriptHalted
PS> $error[0].scriptstacktrace
at InvokeMethodOnTarget, C:\Users\adamed\src\autographps\.devmodule\scriptclass\0.20.1\src\scriptobject\dsl\MethodDsl.ps1: line 97
at <ScriptBlock>, C:\Users\adamed\src\autographps\.devmodule\scriptclass\0.20.1\src\scriptobject\dsl\MethodDsl.ps1: line 41
at <ScriptBlock>, C:\Users\adamed\src\autographps\.devmodule\scriptclass\0.20.1\src\scriptobject\dsl\MethodDsl.ps1: line 37
at <ScriptBlock>, <No file>: line 1

Expected behavior
Something like an error that says Method 'idontexist' does not exist on class 'IHaveNoMethods', and the stack trace should include the line that tried to invoke the method with |=>.

Desktop (please complete the following information):

  • OS: All OS Versions
  • ScriptClass 0.20.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions