mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-17 05:04:55 +00:00
print file/location/frame when encountering an initial error in dev
This commit is contained in:
@@ -199,9 +199,10 @@ class Watcher extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
manifest_data = new_manifest_data;
|
manifest_data = new_manifest_data;
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
this.emit('error', <ErrorEvent>{
|
this.emit('error', <ErrorEvent>{
|
||||||
message: err.message
|
type: 'manifest',
|
||||||
|
error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -408,11 +409,11 @@ class Watcher extends EventEmitter {
|
|||||||
}) {
|
}) {
|
||||||
compiler.oninvalid(invalid);
|
compiler.oninvalid(invalid);
|
||||||
|
|
||||||
compiler.watch((err?: Error, result?: CompileResult) => {
|
compiler.watch((error?: Error, result?: CompileResult) => {
|
||||||
if (err) {
|
if (error) {
|
||||||
this.emit('error', <ErrorEvent>{
|
this.emit('error', <ErrorEvent>{
|
||||||
type: name,
|
type: name,
|
||||||
message: err.message
|
error
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.emit('build', {
|
this.emit('build', {
|
||||||
|
|||||||
13
src/cli.ts
13
src/cli.ts
@@ -89,8 +89,17 @@ prog.command('dev')
|
|||||||
});
|
});
|
||||||
|
|
||||||
watcher.on('error', (event: ErrorEvent) => {
|
watcher.on('error', (event: ErrorEvent) => {
|
||||||
console.log(colors.red(`✗ ${event.type}`));
|
const { type, error } = event;
|
||||||
console.log(colors.red(event.message));
|
|
||||||
|
console.log(colors.bold().red(`✗ ${type}`));
|
||||||
|
|
||||||
|
if (error.loc) {
|
||||||
|
let file = error.loc.file && `${path.relative(process.cwd(), error.loc.file)} (${error.loc.line}:${error.loc.column})`;
|
||||||
|
if (file) console.log(colors.bold(file));
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(colors.red(event.error.message));
|
||||||
|
if (error.frame) console.log(error.frame);
|
||||||
});
|
});
|
||||||
|
|
||||||
watcher.on('fatal', (event: FatalEvent) => {
|
watcher.on('fatal', (event: FatalEvent) => {
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export type ReadyEvent = {
|
|||||||
|
|
||||||
export type ErrorEvent = {
|
export type ErrorEvent = {
|
||||||
type: string;
|
type: string;
|
||||||
message: string;
|
error: Error;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FatalEvent = {
|
export type FatalEvent = {
|
||||||
|
|||||||
Reference in New Issue
Block a user