BBx-Kitchen / bbj-language-server

BBj Language Server
MIT License
7 stars 6 forks source link

THROW verb in methods #46

Closed StephanWald closed 1 year ago

StephanWald commented 1 year ago

This is valid, THROW is resulting in the falsely flagged error on methodend:

class public Sample

    method public String write(String dr!)
        seterr writeErr
        PRINT dr!
        methodret dr!

        writeErr:
        throw errmes(-1), err
    methodend

classend
dhuebner commented 1 year ago

@StephanWald Throw Verb allows following syntax: THROW str{,int}{,ERR=lineref}. The example above doesn't match this definition. https://documentation.basis.cloud/BASISHelp/WebHelp/commands/throw_verb.htm

I know we where talking a bit about weeks ago where it turned out that inside the methods the syntax is a bit different, without =lineref. Are there other differences? Could you point me to the corresponding documentation?

TODO

StephanWald commented 1 year ago

The "err" in the sample is not meant to be the "err=" clause, but is the "ERR" builtin system variable that returns an error code.

You can play with it by doing something like this in the console:

>lkjlkj
!ERROR=20  (Syntax Error: lkjlkj)
>? err
 20
>

ERR always returns the last BASIC error code. In the THROW sample it's simply used to pass on the original err code as is, instead of ERR any integer would be valid.

class public Sample

    method public String write(String dr!)
        seterr writeErr
        PRINT dr!
        methodret dr!

        writeErr:
        throw "There was some Error!",201
    methodend

classend
dhuebner commented 1 year ago

Fixed