Skip to content

Commit fb6ce55

Browse files
committed
Fix loader logic to handle exception
Signed-off-by: Calvin Cheng <linchuan.cheng@gmail.com>
1 parent 3565121 commit fb6ce55

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

webpack_loader/loader.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ def get_assets(self):
3838
return self.load_assets()
3939

4040
def filter_chunks(self, chunks):
41-
for chunk_name in chunks:
41+
for c in chunks:
42+
chunk_name = c.get('name')
4243
ignore = any(regex.match(chunk_name)
4344
for regex in self.config['ignores'])
4445
if not ignore:
@@ -49,10 +50,13 @@ def filter_chunks(self, chunks):
4950
yield chunk
5051

5152
def get_chunk_url(self, chunk_name):
52-
chunk = self.get_assets().get('assets').get(chunk_name)
53-
public_path = chunk.get('publicPath')
54-
if public_path:
55-
return public_path
53+
try:
54+
chunk = self.get_assets().get('assets').get(chunk_name)
55+
public_path = chunk.get('publicPath')
56+
if public_path:
57+
return public_path
58+
except Exception as e:
59+
print(e)
5660

5761
relpath = '{0}{1}'.format(
5862
self.config['BUNDLE_DIR_NAME'], chunk_name
@@ -83,7 +87,8 @@ def get_bundle(self, bundle_name):
8387
if assets.get('status') == 'done':
8488
chunks = assets['chunks'].get(bundle_name, None)
8589
if chunks is None:
86-
raise WebpackBundleLookupError('Cannot resolve bundle {0}.'.format(bundle_name))
90+
raise WebpackBundleLookupError(
91+
'Cannot resolve bundle {0}.'.format(bundle_name))
8792
return self.filter_chunks(chunks)
8893

8994
elif assets.get('status') == 'error':

0 commit comments

Comments
 (0)