Skip to content

Commit 153a67e

Browse files
UnikZnex3
authored andcommitted
Handle http errors trying to find package (#1552)
1 parent a6fc90b commit 153a67e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/src/source/hosted.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,17 @@ class BoundHostedSource extends CachedSource {
315315
/// Always throws an error, either the original one or a better one.
316316
void _throwFriendlyError(
317317
error, StackTrace stackTrace, String package, String url) {
318-
if (error is PubHttpException && error.response.statusCode == 404) {
319-
throw new PackageNotFoundException(
320-
"Could not find package $package at $url.", error, stackTrace);
318+
if (error is PubHttpException) {
319+
if (error.response.statusCode == 404) {
320+
throw new PackageNotFoundException(
321+
"Could not find package $package at $url.", error, stackTrace);
322+
}
323+
324+
fail(
325+
"${error.response.statusCode} ${error.response.reasonPhrase} trying "
326+
"to find package $package at $url.",
327+
error,
328+
stackTrace);
321329
}
322330

323331
if (error is io.SocketException) {

0 commit comments

Comments
 (0)