错误代码

micro:bit 错误代码及其含义

micro:bit出现错误

micro:bit可能遇到阻止代码运行的情况。当发生这种情况时,悲伤的表情会出现在micro:bit屏幕 上(见图) 紧接着出现识别错误的代码。

无论这种情况何时发生,你应该:

  • 按下Mico:bit背面的复位键,重新启动程序。
  • 将脚本文件再次存储至micro:bit.

如果问题继续存在,请向我们报告这一问题。

提交支持服务单

下面是识别错误代码号和它们所表示的含义︰

Hardware errors

Error number What this means
10 The micro:bit's I2C bus is not working. The device might be physically damaged.
20 There is no free memory on the micro:bit. Your program might be too complex or contain a lot of large variables. Try reducing your code by making functions out of large sections.
30 Corruption detected in the micro:bit heap space (memory allocated usually for the storage of variables). Try flashing a different .hex file to your device
40 Your micro:bit can't execute your script properly. Flash a different .hex file to it, then try flashing and running your previous script again.
42 Your micro:bit can't execute your script properly. Flash a different .hex file to it, then try flashing and running your previous script again.
43 An error occurred with the micro:bit's radio component.
50 An error occurred with the micro:bit's accelerometer component.
51 An error occurred with the micro:bit's magnetometer component.
98 Assertion failed. A MakeCode error that occurs when the condition in an assert was false.

MakeCode Editor errors

Error codes generated from the MakeCode Editor. In all these cases, please report the error to us, or if you are comfortable using Github, submit an issue on the code repository.

提交支持服务单

Garbage collector errors

Error number What this means
840 Allocation pointer is null or invalid.
841 Garbage collection work queue error.
843 VTable entry is not free.
844 GC allocation failed for requested number of bytes.
846 Invalid allocation thread.
848 Allocation pointer beyond allocation header.
849 Allocation pointer is null.

Program access errors

Error number What this means
901 The type header for the object is not valid.
902 The object data portion is greater than the length defined for it.
903 An object reference was deleted and the object is no longer valid.
904 The object size doesn’t match the size defined for the type.
905 An object vtable is invalid or not initialized.
906 An internal resource error.
907 The specified device resource is not present.
909 The argument value is out of range or the type or format is invalid.

JavaScript runtime codes

These occur for example, when the static type of x is a class c, the dynamic type of x isn’t c, and you try to access a field on x or call a method on x, you will get one of the following codes, depending on dynamic type of x.

Error number What this means
980 When value of x is undefined.
981 When value of x is true or false.
982 When x is a number.
983 When x is a string.
984 When x is object of some type.
985 When x is a function.
989 When x is a null.
Selecting this opens external content from our support system, which adheres to their privacy policy.