mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Properly extend Error instead of implementing it, update the Error message and stack to appear in the console and error activity
This commit is contained in:
committed by
Vladimir Enchev
parent
bc3910f9c8
commit
89ee3dc717
47
tns-core-modules/utils/debug-common.ts
Normal file
47
tns-core-modules/utils/debug-common.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { knownFolders } from "file-system"
|
||||
|
||||
export var debug = true;
|
||||
|
||||
var applicationRootPath: string;
|
||||
function ensureAppRootPath() {
|
||||
if (!applicationRootPath) {
|
||||
applicationRootPath = knownFolders.currentApp().path;
|
||||
applicationRootPath = applicationRootPath.substr(0, applicationRootPath.length - "app/".length);
|
||||
}
|
||||
}
|
||||
|
||||
export class Source {
|
||||
private _uri: string;
|
||||
private _line: number;
|
||||
private _column: number;
|
||||
|
||||
private static _source: symbol = Symbol("source");
|
||||
|
||||
constructor(uri: string, line: number, column: number) {
|
||||
ensureAppRootPath();
|
||||
|
||||
if (uri.length > applicationRootPath.length && uri.substr(0, applicationRootPath.length) === applicationRootPath) {
|
||||
this._uri = "file://" + uri.substr(applicationRootPath.length);
|
||||
} else {
|
||||
this._uri = uri;
|
||||
}
|
||||
this._line = line;
|
||||
this._column = column;
|
||||
}
|
||||
|
||||
get uri(): string { return this._uri; }
|
||||
get line(): number { return this._line; }
|
||||
get column(): number { return this._column; }
|
||||
|
||||
public toString() {
|
||||
return this._uri + ":" + this._line + ":" + this._column;
|
||||
}
|
||||
|
||||
public static get(object: any): Source {
|
||||
return object[Source._source];
|
||||
}
|
||||
|
||||
public static set(object: any, src: Source) {
|
||||
object[Source._source] = src;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user