File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 1313from webpack_loader .exceptions import (
1414 WebpackError ,
1515 WebpackLoaderBadStatsError ,
16- WebpackLoaderTimeoutError
16+ WebpackLoaderTimeoutError ,
17+ WebpackBundleLookupError
1718)
1819from webpack_loader .utils import get_loader
1920
@@ -153,6 +154,14 @@ def test_reporting_errors(self):
153154 except WebpackError as e :
154155 self .assertIn ("Cannot resolve module 'the-library-that-did-not-exist'" , str (e ))
155156
157+ def test_missing_bundle (self ):
158+ missing_bundle_name = 'missing_bundle'
159+ self .compile_bundles ('webpack.config.simple.js' )
160+ try :
161+ get_loader (DEFAULT_CONFIG ).get_bundle (missing_bundle_name )
162+ except WebpackBundleLookupError as e :
163+ self .assertIn ('Cannot resolve bundle {0}' .format (missing_bundle_name ), str (e ))
164+
156165 def test_missing_stats_file (self ):
157166 stats_file = settings .WEBPACK_LOADER [DEFAULT_CONFIG ]['STATS_FILE' ]
158167 if os .path .exists (stats_file ):
Original file line number Diff line number Diff line change 1- __all__ = ('WebpackError' , 'WebpackLoaderBadStatsError' )
1+ __all__ = (
2+ 'WebpackError' ,
3+ 'WebpackLoaderBadStatsError' ,
4+ 'WebpackLoaderTimeoutError' ,
5+ 'WebpackBundleLookupError'
6+ )
27
38
49class WebpackError (Exception ):
@@ -11,3 +16,7 @@ class WebpackLoaderBadStatsError(Exception):
1116
1217class WebpackLoaderTimeoutError (Exception ):
1318 pass
19+
20+
21+ class WebpackBundleLookupError (Exception ):
22+ pass
Original file line number Diff line number Diff line change 77from .exceptions import (
88 WebpackError ,
99 WebpackLoaderBadStatsError ,
10- WebpackLoaderTimeoutError
10+ WebpackLoaderTimeoutError ,
11+ WebpackBundleLookupError
1112)
1213from .config import load_config
1314
@@ -76,7 +77,9 @@ def get_bundle(self, bundle_name):
7677 )
7778
7879 if assets .get ('status' ) == 'done' :
79- chunks = assets ['chunks' ][bundle_name ]
80+ chunks = assets ['chunks' ].get (bundle_name , None )
81+ if chunks is None :
82+ raise WebpackBundleLookupError ('Cannot resolve bundle {0}.' .format (bundle_name ))
8083 return self .filter_chunks (chunks )
8184
8285 elif assets .get ('status' ) == 'error' :
You can’t perform that action at this time.
0 commit comments