Skip to content

Commit 14af9a2

Browse files
phalaowais
authored andcommitted
Generalise exceptions and fix regression (#125)
* Fix regression for file opening * Standardize exceptions raised by django-webpack-loader. Make WebpackError the main exception, and have the rest of the exceptions inherit form it. * Create base exception
1 parent 3eb311e commit 14af9a2

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

webpack_loader/exceptions.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,31 @@
66
)
77

88

9-
class WebpackError(Exception):
10-
pass
9+
class BaseWebpackLoaderException(Exception):
10+
"""
11+
Base exception for django-webpack-loader.
12+
"""
1113

1214

13-
class WebpackLoaderBadStatsError(Exception):
14-
pass
15+
class WebpackError(BaseWebpackLoaderException):
16+
"""
17+
General webpack loader error.
18+
"""
1519

1620

17-
class WebpackLoaderTimeoutError(Exception):
18-
pass
21+
class WebpackLoaderBadStatsError(BaseWebpackLoaderException):
22+
"""
23+
The stats file does not contain valid data.
24+
"""
1925

2026

21-
class WebpackBundleLookupError(Exception):
22-
pass
27+
class WebpackLoaderTimeoutError(BaseWebpackLoaderException):
28+
"""
29+
The bundle took too long to compile.
30+
"""
31+
32+
33+
class WebpackBundleLookupError(BaseWebpackLoaderException):
34+
"""
35+
The bundle name was invalid.
36+
"""

webpack_loader/loader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import time
3+
from io import open
34

45
from django.conf import settings
56
from django.contrib.staticfiles.storage import staticfiles_storage

0 commit comments

Comments
 (0)