Skip to content

Commit

Permalink
dct: visualize on compilation failure
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Nov 13, 2023
1 parent 97c45f7 commit afc60a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/app/dct/dct.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ export class DCTComponent implements OnInit, AfterViewInit {
verbose: true,
debug: debug,
});
} catch (e) {
} catch (e: any) {
console.error(e);
this.schemaOutput = e.stdout ?? String();
return false;
}

Expand All @@ -158,9 +159,13 @@ export class DCTComponent implements OnInit, AfterViewInit {
}

public async visualizeSchema() {
if (await this.compileSchema(true)) {
await this.compileSchema(true);

// Check if output contains a DAG
// This can be the case even if the compiler fails
if (this.schemaOutput.includes('digraph')) {
this.refreshVisualizer();
this.tabs.set(this.visualizerTab)
this.tabs.set(this.visualizerTab);
}
}

Expand Down
16 changes: 11 additions & 5 deletions src/app/wasm.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,17 @@ export class WasmService {
*/
public async stdout(fun: WasmFunction, ...args: Parameters<WasmFunction>): Promise<string> {
const stdout: string[] = [];
await fun(args[0], {
...args[1] ?? {},
print: (line) => stdout.push(line) && window.console.log_play(line),
});
return stdout.join('\n');
try {
await fun(args[0], {
...args[1] ?? {},
print: (line) => stdout.push(line) && window.console.log_play(line),
});

return stdout.join('\n');
} catch (e: any) {
e.stdout = stdout.join('\n');
throw e;
}
}

/**
Expand Down

0 comments on commit afc60a8

Please sign in to comment.