瀏覽代碼

Throw a more readable error for i3dm external uri fetching

Garrett Johnson 4 年之前
父節點
當前提交
0a59fc9f74
共有 1 個文件被更改,包括 13 次插入1 次删除
  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 );