Better error handling

This commit is contained in:
Pieter Vander Vennet 2022-04-22 03:17:40 +02:00
parent 700cad1000
commit 979041dacb
6 changed files with 44 additions and 21 deletions

View file

@ -216,13 +216,18 @@ export class Fuse<T> extends DesugaringStep<T> {
const information = []
for (let i = 0; i < this.steps.length; i++) {
const step = this.steps[i];
let r = step.convert(json, "While running step " + step.name + ": " + context)
errors.push(...r.errors ?? [])
warnings.push(...r.warnings ?? [])
information.push(...r.information ?? [])
json = r.result
if (errors.length > 0) {
break;
try{
let r = step.convert(json, "While running step " + step.name + ": " + context)
errors.push(...r.errors ?? [])
warnings.push(...r.warnings ?? [])
information.push(...r.information ?? [])
json = r.result
if (errors.length > 0) {
break;
}
}catch(e){
console.error("Step "+step.name+" failed due to "+e);
throw e
}
}
return {

View file

@ -479,6 +479,7 @@ export class PrepareTheme extends Fuse<LayoutConfigJson> {
}) {
super(
"Fully prepares and expands a theme",
new AddContextToTransltionsInLayout(),
new PreparePersonalTheme(state),
new WarnForUnsubstitutedLayersInTheme(),

View file

@ -217,12 +217,17 @@ class MiscThemeChecks extends DesugaringStep<LayoutConfigJson>{
convert(json: LayoutConfigJson, context: string): { result: LayoutConfigJson; errors?: string[]; warnings?: string[]; information?: string[] } {
const warnings = []
const errors = []
if(json.id !== "personal" && (json.layers === undefined || json.layers.length === 0)){
errors.push("The theme "+json.id+" has no 'layers' defined ("+context+")")
}
if(json.socialImage === ""){
warnings.push("Social image for theme "+json.id+" is the emtpy string")
}
return {
result :json,
warnings
warnings,
errors
};
}
}
@ -231,8 +236,8 @@ export class PrevalidateTheme extends Fuse<LayoutConfigJson> {
constructor() {
super("Various consistency checks on the raw JSON",
new OverrideShadowingCheck(),
new MiscThemeChecks()
new MiscThemeChecks(),
new OverrideShadowingCheck()
);
}