Skip to content

Commit a36cb28

Browse files
committed
fix: uncaptured error when gen sct file
1 parent 41b37a4 commit a36cb28

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/CodeBuilder.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { exeSuffix, osType } from "./Platform";
5555
import { FileWatcher } from "../lib/node-utility/FileWatcher";
5656
import { STVPFlasherOptions } from './HexUploader';
5757
import * as ArmCpuUtils from './ArmCpuUtils';
58+
import { view_str$gen_sct_failed } from './StringTable';
5859

5960
export interface BuildOptions {
6061

@@ -658,7 +659,7 @@ export class ARMCodeBuilder extends CodeBuilder {
658659
index = storageLayout.RAM[i].id - 1;
659660
break;
660661
default:
661-
throw Error('Unknown RAM Tag !');
662+
throw Error(`${view_str$gen_sct_failed}: Unknown RAM Tag !`);
662663
}
663664

664665
memScatter.ramList[index].memInfo = storageLayout.RAM[i].mem;
@@ -679,7 +680,7 @@ export class ARMCodeBuilder extends CodeBuilder {
679680
index = storageLayout.ROM[i].id - 1;
680681
break;
681682
default:
682-
throw Error('Unknown ROM Tag !');
683+
throw Error(`${view_str$gen_sct_failed}: Unknown ROM Tag !`);
683684
}
684685

685686
memScatter.romList[index].memInfo = storageLayout.ROM[i].mem;
@@ -691,10 +692,10 @@ export class ARMCodeBuilder extends CodeBuilder {
691692
}
692693

693694
if (memScatter.startUpIndex === -1) {
694-
throw Error('MemScatter.startupIndex can\'t be -1');
695+
throw Error(`${view_str$gen_sct_failed}: MemScatter.startupIndex can't be -1`);
695696
}
696697
else if (!memScatter.romList[memScatter.startUpIndex].selected) {
697-
throw Error('the IROM' + (memScatter.startUpIndex - 2).toString() + ' is a startup ROM but it is not selected !');
698+
throw Error(`${view_str$gen_sct_failed}: The IROM' + (memScatter.startUpIndex - 2).toString() + ' is a startup ROM but it is not selected !`);
698699
}
699700

700701
return memScatter;
@@ -1046,8 +1047,12 @@ export class ARMCodeBuilder extends CodeBuilder {
10461047
ldFileList.push(this.convLinkerScriptPathForCompiler(sctPath));
10471048
});
10481049
} else { // auto generate scatter file
1049-
const sctPath = this.GenMemScatterFile(config).path;
1050-
ldFileList.push(this.convLinkerScriptPathForCompiler(sctPath));
1050+
try {
1051+
const sctPath = this.GenMemScatterFile(config).path;
1052+
ldFileList.push(this.convLinkerScriptPathForCompiler(sctPath));
1053+
} catch (error) {
1054+
GlobalEvent.emit('error', error);
1055+
}
10511056
}
10521057
}
10531058
break;

src/StringTable.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@ export const view_str$env_desc$compiler_folder = [
424424

425425
//---------------Other---------------
426426

427+
export const view_str$gen_sct_failed = [
428+
`生成.sct文件失败`,
429+
`Fail to generate .sct file`
430+
][langIndex];
431+
427432
export const view_str$virual_doc_provider_banner = [
428433
`通过修改并保存这个文件来更新项目配置(注意这个文件是临时的,不要使用其他工具打开这个文件)`,
429434
`You can modify the configuration by editing and saving this file.`

0 commit comments

Comments
 (0)