Browse Source

Check res ok

Garrett Johnson 5 years ago
parent
commit
1ea352d337
4 changed files with 40 additions and 4 deletions
  1. 10 1
      src/base/B3DMLoaderBase.js
  2. 10 1
      src/base/CMPTLoaderBase.js
  3. 10 1
      src/base/I3DMLoaderBase.js
  4. 10 1
      src/base/PNTSLoaderBase.js

+ 10 - 1
src/base/B3DMLoaderBase.js

@@ -14,7 +14,16 @@ export class B3DMLoaderBase {
 	load( url ) {
 
 		return fetch( url, this.fetchOptions )
-			.then( res => res.arrayBuffer() )
+			.then( res => {
+
+				if ( ! res.ok ) {
+
+					throw new Error( `Failed to load file "${ url }" with status ${ res.status } : ${ res.statusText }` );
+
+				}
+				return res.arrayBuffer();
+
+			} )
 			.then( buffer => this.parse( buffer ) );
 
 	}

+ 10 - 1
src/base/CMPTLoaderBase.js

@@ -12,7 +12,16 @@ export class CMPTLoaderBase {
 	load( url ) {
 
 		return fetch( url, this.fetchOptions )
-			.then( res => res.arrayBuffer() )
+			.then( res => {
+
+				if ( ! res.ok ) {
+
+					throw new Error( `Failed to load file "${ url }" with status ${ res.status } : ${ res.statusText }` );
+
+				}
+				return res.arrayBuffer();
+
+			} )
 			.then( buffer => this.parse( buffer ) );
 
 	}

+ 10 - 1
src/base/I3DMLoaderBase.js

@@ -14,7 +14,16 @@ export class I3DMLoaderBase {
 	load( url ) {
 
 		return fetch( url, this.fetchOptions )
-			.then( res => res.arrayBuffer() )
+			.then( res => {
+
+				if ( ! res.ok ) {
+
+					throw new Error( `Failed to load file "${ url }" with status ${ res.status } : ${ res.statusText }` );
+
+				}
+				return res.arrayBuffer();
+
+			} )
 			.then( buffer => this.parse( buffer ) );
 
 	}

+ 10 - 1
src/base/PNTSLoaderBase.js

@@ -14,7 +14,16 @@ export class PNTSLoaderBase {
 	load( url ) {
 
 		return fetch( url, this.fetchOptions )
-			.then( res => res.arrayBuffer() )
+			.then( res => {
+
+				if ( ! res.ok ) {
+
+					throw new Error( `Failed to load file "${ url }" with status ${ res.status } : ${ res.statusText }` );
+
+				}
+				return res.arrayBuffer();
+
+			} )
 			.then( buffer => this.parse( buffer ) );
 
 	}