Skip to content

Commit 9a1e20e

Browse files
authored
Merge pull request #106 from t-kazu/feature/no-error-extensions-blocks
拡張機能のブロックを変換しようとした時はnullを返すようにします
2 parents bc46247 + 7d60dd4 commit 9a1e20e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/ruby-generator/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import _ from 'lodash';
2+
import minilog from 'minilog';
23

34
import GeneratedBlocks from './generated.js';
45
import MathBlocks from './math.js';
@@ -495,11 +496,18 @@ export default function (Blockly) {
495496

496497
Blockly.Ruby.blockToCode_ = Blockly.Ruby.blockToCode;
497498

499+
minilog.enable();
500+
const log = minilog('ruby-generator');
498501
Blockly.Ruby.blockToCode = function (block) {
499502
if (block && !block.disabled && block.type.match(/^hardware_/)) {
500503
this.definitions_.prepare__init_hardware = 'init_hardware';
501504
}
502-
return this.blockToCode_(block);
505+
try {
506+
return this.blockToCode_(block);
507+
} catch (error) {
508+
log.error(`'${block.type}' block is not unsupported to generate Ruby code. Please implement it.`);
509+
return null;
510+
}
503511
};
504512

505513
Blockly = GeneratedBlocks(Blockly);

0 commit comments

Comments
 (0)