How to throw errors?

I’m currently writing some TypeScript, (in MakeCode Arcade obviously) and it currently isn’t but I plan on it becoming an extension. It appears that throw new Error(); is not supported, as Error isn’t defined. What are the options available to alert people to runtime errors?

If this style of writing extensions isn’t commonly done, I’m open on other ways to structure my extension. (It’s :sparkles: something :sparkles: (that may or may never get released, who knows) that parses images with a specific format, and if the dev pastes in the wrong type of image, or the format is unsupported, or bad values in parsing, I want to throw an error.)

1 Like

I belive raising exceptions is a part of the ommited features for the modified TS build MakeCode is using. You could try structuring a custom(?) error splash screen or something of that kind.

1 Like

@UnsignedArduino you can throw strings! e.g.

throw "nice try!"

@S0m3_random_guy we do actually support exceptions!

3 Likes

You can try control.panic(/*insert a number*/)
The number doesn’t matter

I’ve tried that, but a single number isn’t really that informative :sweat_smile:
Plus, I’m not sure which numbers are already used by Arcade, because I’m not sure how much this page covers.

2 Likes

wait you want a extension to throw errors?

if you really want to use a panic code you can, but you want to use something that isn’t in the 9XXs or the 0XXs since those are reserved for system errors.

all of the codes that we use are here:

but really, a string is so much easier to read :slight_smile:

3 Likes

Well, I don’t think I would need an extension, I just needed a way to crash the program, hopefully with an informative message and it appears that throw "string"; does what I want.

1 Like

what if you do every game update then put a music block inside of it it makes me crash btw it has to be 1 milisecond

1 Like