Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try / catch not working with 'normal errors' like null pointer exceptions #5852

Open
jwunderl opened this issue Apr 15, 2023 · 0 comments
Open
Labels
bug Something isn't working typescript

Comments

@jwunderl
Copy link
Member

jwunderl commented Apr 15, 2023

Describe the bug

It looks like try / catches only work with explicit 'throws', and not normal errors (too big allocation, out of memory, null pointer exceptions)

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://makecode.com/_7J3PqJbPUDvU
  2. run game (hardware / sim have same behavior)
  3. See it works; comment out line 3 (throw "error!")
  4. run game
  5. See error

Expected behavior

Ideally it'd be nice for catch to support these, but if not we should probably add it back in as a caveat in https://makecode.com/language

Additional context

let mySprite: Sprite;
try {
    // throw "error!"
    mySprite.setPosition(1, 2)
} catch (e) {
    mySprite = sprites.create(img`
        . . . . . . . . . . . . . . . .
        . . . . . . . . . . b 5 b . . .
        . . . . . . . . . b 5 b . . . .
        . . . . . . b b b b b b . . . .
        . . . . . b b 5 5 5 5 5 b . . .
        . b b b b b 5 5 5 5 5 5 5 b . .
        . b d 5 b 5 5 5 5 5 5 5 5 b . .
        . . b 5 5 b 5 d 1 f 5 d 4 f . .
        . . b d 5 5 b 1 f f 5 4 4 c . .
        b b d b 5 5 5 d f b 4 4 4 4 4 b
        b d d c d 5 5 b 5 4 4 4 4 4 b .
        c d d d c c b 5 5 5 5 5 5 5 b .
        c b d d d d d 5 5 5 5 5 5 5 b .
        . c d d d d d d 5 5 5 5 5 d b .
        . . c b d d d d d 5 5 5 b b . .
        . . . c c c c c c c c b b . . .
    `)
}
@jwunderl jwunderl changed the title try / catch not working with ' try / catch not working with 'normal errors' like null pointer exceptions Apr 15, 2023
@jwunderl jwunderl added bug Something isn't working typescript labels Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working typescript
Projects
None yet
Development

No branches or pull requests

1 participant