Skip to content

Commit

Permalink
feat(logging): log node creation errors (#625)
Browse files Browse the repository at this point in the history
* fix: log node creation errors

* fix: show error stack

* fix: throw error if viewClass not found
  • Loading branch information
farfromrefug committed Apr 9, 2020
1 parent 9ce38a0 commit b502fc8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
4 changes: 3 additions & 1 deletion platform/nativescript/element-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export function getViewClass(elementName) {
try {
return entry.resolver()
} catch (e) {
throw new TypeError(`Could not load view for: ${elementName}. ${e}`)
throw new TypeError(
`Could not load view for: ${elementName}. ${e} ${e.stack}`
)
}
}

Expand Down
24 changes: 20 additions & 4 deletions platform/nativescript/renderer/DocumentNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,34 @@ export default class DocumentNode extends ViewNode {
}

static createComment(text) {
return new CommentNode(text)
try {
return new CommentNode(text)
} catch (err) {
console.log(err)
}
}

static createElement(tagName) {
return new ElementNode(tagName)
try {
return new ElementNode(tagName)
} catch (err) {
console.log(err)
}
}

static createElementNS(namespace, tagName) {
return new ElementNode(namespace + ':' + tagName)
try {
return new ElementNode(namespace + ':' + tagName)
} catch (err) {
console.log(err)
}
}

static createTextNode(text) {
return new TextNode(text)
try {
return new TextNode(text)
} catch (err) {
console.log(err)
}
}
}
5 changes: 5 additions & 0 deletions platform/nativescript/renderer/ElementNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export default class ElementNode extends ViewNode {
this.tagName = tagName

const viewClass = getViewClass(tagName)
if (!viewClass) {
throw new TypeError(
`No native component for element tag name ${tagName}.`
)
}
this._nativeView = new viewClass()
this._nativeView[VUE_ELEMENT_REF] = this
}
Expand Down

0 comments on commit b502fc8

Please sign in to comment.