learn.forge.viewhubmodels icon indicating copy to clipboard operation
learn.forge.viewhubmodels copied to clipboard

Improved error messaging when a viewable is absent

Open jeanflowerADSK opened this issue 4 years ago • 4 comments

Many of my designs in Fusion Teams don't have viewables, even for models that are capable of having a viewable.
When I was expecting a view but didn't get one, the viewer stays blank and in the console I saw

ForgeViewer.js:46 onDocumentLoadFailure() - errorCode:9
onDocumentLoadFailure @ ForgeViewer.js:46

This is the function around ForgeViewer.js:46:

function onDocumentLoadFailure(viewerErrorCode) {
 console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
}

I don't know what errorCode 9 means. Adding the following code makes things a little less opaque for new users. We just need a small code change to ForgeViewer.js

function onDocumentLoadFailure(viewerErrorCode, viewerErrorMsg) {.  <--- add 2nd argument
    console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode);
    console.error('onDocumentLoadFailure() - errorMsg:' + viewerErrorMsg);     <---- add this line
  }
}

and the console now reads

ForgeViewer.js:46 onDocumentLoadFailure() - errorCode:9
onDocumentLoadFailure @ ForgeViewer.js:46
ForgeViewer.js:47 onDocumentLoadFailure() - errorMsg:No viewable content
onDocumentLoadFailure @ ForgeViewer.js:47

The "No viewable content" gives me a clue about what's happened.

jeanflowerADSK avatar Dec 14 '20 13:12 jeanflowerADSK

This implementation would be useful. Also, we could pass the "viewerErrorMsg" together with the "errorCode". The code would be like the one below on ForgeViewer.js

function onDocumentLoadFailure(viewerErrorCode, viewerErrorMsg) {
console.error('onDocumentLoadFailure() - errorCode:' + viewerErrorCode + '\n- errorMessage:' + viewerErrorMsg);
}

And the console would read

onDocumentLoadFailure() - errorCode:9
- errorMessage:No viewable content

JoaoMartins-callmeJohn avatar Jan 05 '21 18:01 JoaoMartins-callmeJohn

It looks like we make almost the same suggestion. But I'm not sure if your code snippet would compile without the additional viewerErrorMsg argument.

jeanflowerADSK avatar Jan 06 '21 09:01 jeanflowerADSK

Yes, my bad! Edited!

JoaoMartins-callmeJohn avatar Jan 06 '21 12:01 JoaoMartins-callmeJohn

thank you both.

@JoaoMartins-Forge can you please create PRs to https://github.com/Autodesk-Forge/learn.forge.viewhubmodels (3LO code for tutorial) https://github.com/Autodesk-Forge/learn.forge.viewmodels (2LO code for tutorial) https://github.com/Developer-Autodesk/forge.learning (tutorial)

augustogoncalves avatar Jan 06 '21 13:01 augustogoncalves