Browse Source

Throw a more readable error for i3dm external uri fetching

Garrett Johnson 4 years ago
parent
commit
0a59fc9f74
1 changed files with 13 additions and 1 deletions
  1. 13 1
      src/base/I3DMLoaderBase.js

+ 13 - 1
src/base/I3DMLoaderBase.js

@@ -110,7 +110,19 @@ export class I3DMLoaderBase {
 
 			const externalUri = arrayToString( bodyBytes );
 			promise = fetch( externalUri, this.fetchOptions )
-				.then( res => res.buffer )
+				.then( res => {
+
+					if ( res.ok ) {
+
+						return res.buffer();
+
+					} else {
+
+						throw new Error( `I3DMLoaderBase : Failed to load ${ externalUri } with status ${ res.status }: ${ res.statusText }` );
+
+					}
+
+				} )
 				.then( buffer => {
 
 					glbBytes = new Uint8Array( buffer );