Skip to content

Commit 3354c59

Browse files
committed
maor errors
1 parent 9d39765 commit 3354c59

24 files changed

+424
-6
lines changed

dist/cmd_error.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Parser } from "./parser";
2+
export declare class CmdError {
3+
args: string[];
4+
env: string[];
5+
err: any;
6+
exit: number;
7+
filename: string;
8+
output: string;
9+
root: string;
10+
constructor(data: any, parser?: Parser);
11+
}

dist/cmd_error.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Parser } from "./parser";
2+
export class CmdError {
3+
constructor(data, parser) {
4+
this.args = data.args;
5+
this.env = data.env;
6+
this.exit = data.exit;
7+
this.filename = data.filename;
8+
this.output = data.output;
9+
this.root = data.root;
10+
parser = parser || new Parser();
11+
this.err = parser.parseError(data.err);
12+
}
13+
}
14+
// args: [ 'ech', 'Hello World' ],
15+
// env: [
16+
// ],
17+
// err: 'exec: "ech": executable file not found in $PATH',
18+
// exit: -1,
19+
// filename: 'usage.md',
20+
// output: '',
21+
// root: '/Users/markbates/Library/CloudStorage/Dropbox/dev/guides/hypeviewer',
22+
// type: 'hype.CmdError'

dist/execute_error.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Parser } from "./parser";
2+
export declare class ExecuteError {
3+
filename: string;
4+
root: string;
5+
err: any;
6+
constructor(data: any, parser?: Parser);
7+
}

dist/execute_error.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Parser } from "./parser";
2+
export class ExecuteError {
3+
constructor(data, parser) {
4+
this.filename = data.filename;
5+
this.root = data.root;
6+
parser = parser || new Parser();
7+
this.err = parser.parseError(data.err);
8+
}
9+
}

dist/gotypes.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
declare let gotypes: {
22
Body: string;
33
Cmd: string;
4+
CmdError: string;
45
CmdResult: string;
56
Element: string;
7+
ExecuteError: string;
68
FencedCode: string;
79
Figcaption: string;
810
Figure: string;
911
Heading: string;
12+
HypeError: string;
1013
Image: string;
1114
Include: string;
1215
InlineCode: string;
@@ -15,7 +18,9 @@ declare let gotypes: {
1518
OL: string;
1619
Page: string;
1720
Paragraph: string;
21+
ParseError: string;
1822
Ref: string;
23+
RunError: string;
1924
Snippet: string;
2025
SourceCode: string;
2126
TD: string;

dist/gotypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
let gotypes = {
22
Body: "*hype.Body",
33
Cmd: "*hype.Cmd",
4+
CmdError: "hype.CmdError",
45
CmdResult: "*hype.CmdResult",
56
Element: "*hype.Element",
7+
ExecuteError: "hype.ExecuteError",
68
FencedCode: "*hype.FencedCode",
79
Figcaption: "*hype.Figcaption",
810
Figure: "*hype.Figure",
911
Heading: "hype.Heading",
12+
HypeError: "hype.HypeError",
1013
Image: "*hype.Image",
1114
Include: "*hype.Include",
1215
InlineCode: "*hype.InlineCode",
@@ -15,7 +18,9 @@ let gotypes = {
1518
OL: "*hype.OL",
1619
Page: "*hype.Page",
1720
Paragraph: "*hype.Paragraph",
21+
ParseError: "hype.ParseError",
1822
Ref: "*hype.Ref",
23+
RunError: "clam.RunError",
1924
Snippet: "hype.Snippet",
2025
SourceCode: "*hype.SourceCode",
2126
TD: "*hype.TD",

dist/index.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ import path from 'path-browserify';
44
let gotypes = {
55
Body: "*hype.Body",
66
Cmd: "*hype.Cmd",
7+
CmdError: "hype.CmdError",
78
CmdResult: "*hype.CmdResult",
89
Element: "*hype.Element",
10+
ExecuteError: "hype.ExecuteError",
911
FencedCode: "*hype.FencedCode",
1012
Figcaption: "*hype.Figcaption",
1113
Figure: "*hype.Figure",
1214
Heading: "hype.Heading",
15+
HypeError: "hype.HypeError",
1316
Image: "*hype.Image",
1417
Include: "*hype.Include",
1518
InlineCode: "*hype.InlineCode",
@@ -18,7 +21,9 @@ let gotypes = {
1821
OL: "*hype.OL",
1922
Page: "*hype.Page",
2023
Paragraph: "*hype.Paragraph",
24+
ParseError: "hype.ParseError",
2125
Ref: "*hype.Ref",
26+
RunError: "clam.RunError",
2227
Snippet: "hype.Snippet",
2328
SourceCode: "*hype.SourceCode",
2429
TD: "*hype.TD",
@@ -607,6 +612,37 @@ function newUUID() {
607612
return `heading-${v4()}`;
608613
}
609614

615+
class CmdError {
616+
constructor(data, parser) {
617+
this.args = data.args;
618+
this.env = data.env;
619+
this.exit = data.exit;
620+
this.filename = data.filename;
621+
this.output = data.output;
622+
this.root = data.root;
623+
parser = parser || new Parser();
624+
this.err = parser.parseError(data.err);
625+
}
626+
}
627+
// args: [ 'ech', 'Hello World' ],
628+
// env: [
629+
// ],
630+
// err: 'exec: "ech": executable file not found in $PATH',
631+
// exit: -1,
632+
// filename: 'usage.md',
633+
// output: '',
634+
// root: '/Users/markbates/Library/CloudStorage/Dropbox/dev/guides/hypeviewer',
635+
// type: 'hype.CmdError'
636+
637+
class ExecuteError {
638+
constructor(data, parser) {
639+
this.filename = data.filename;
640+
this.root = data.root;
641+
parser = parser || new Parser();
642+
this.err = parser.parseError(data.err);
643+
}
644+
}
645+
610646
class FencedCode extends Element {
611647
constructor(fc) {
612648
super(fc);
@@ -673,6 +709,15 @@ class Page extends Element {
673709
}
674710
}
675711

712+
class ParseError {
713+
constructor(data, parser) {
714+
this.filename = data.filename;
715+
this.root = data.root;
716+
parser = parser || new Parser();
717+
this.err = parser.parseError(data.err);
718+
}
719+
}
720+
676721
class Ref extends Element {
677722
constructor(r) {
678723
super(r);
@@ -776,6 +821,22 @@ class Parser {
776821
data.nodes = this.parseNodes(data.nodes);
777822
return new Document(data);
778823
}
824+
parseError(data) {
825+
switch (data.type) {
826+
case gotypes.ExecuteError:
827+
return new ExecuteError(data, this);
828+
case gotypes.CmdError:
829+
return new CmdError(data, this);
830+
case gotypes.ParseError:
831+
return new ParseError(data, this);
832+
default:
833+
if (data.type === undefined) {
834+
return data;
835+
}
836+
console.warn("parseError: unknown type: ", data.type);
837+
return data;
838+
}
839+
}
779840
parseNodes(nodes = []) {
780841
let ret = [];
781842
nodes.forEach((n) => {

dist/parse_error.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Parser } from "./parser";
2+
export declare class ParseError {
3+
filename: string;
4+
root: string;
5+
err: any;
6+
constructor(data: any, parser?: Parser);
7+
}

dist/parse_error.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Parser } from "./parser";
2+
export class ParseError {
3+
constructor(data, parser) {
4+
this.filename = data.filename;
5+
this.root = data.root;
6+
parser = parser || new Parser();
7+
this.err = parser.parseError(data.err);
8+
}
9+
}

dist/parser.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ export declare class Parser {
33
handlers: any;
44
constructor();
55
parse(data: any): Document;
6+
parseError(data: any): any;
67
private parseNodes;
78
}

0 commit comments

Comments
 (0)