From 35730f747701866ee59967f366df1a0146caddd5 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 18 Dec 2017 13:11:55 -0800 Subject: [PATCH] Annotate fail with @alwaysThrows, Remove unreachable throws (#1763) https://github.com/dart-lang/sdk/issues/31384 was fixed in https://github.com/dart-lang/sdk/commit/0a6253312f Available in Dart 2.0.0-dev.12.0 --- lib/src/barback/transformer_isolate.dart | 1 - lib/src/pubspec.dart | 3 --- lib/src/utils.dart | 2 ++ test/descriptor_server.dart | 1 - 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/src/barback/transformer_isolate.dart b/lib/src/barback/transformer_isolate.dart index 26b599467..7dcdd34a7 100644 --- a/lib/src/barback/transformer_isolate.dart +++ b/lib/src/barback/transformer_isolate.dart @@ -98,7 +98,6 @@ class TransformerIsolate { // failed was the one we were loading transformers from, throw an // application exception with a more user-friendly message. fail('Transformer library "$packageUri" not found.', error, stackTrace); - return null; } } diff --git a/lib/src/pubspec.dart b/lib/src/pubspec.dart index 7965438f0..318636080 100644 --- a/lib/src/pubspec.dart +++ b/lib/src/pubspec.dart @@ -880,9 +880,6 @@ class Pubspec { if (node == null || node.value == null) return new YamlList(); if (node is YamlList) return node; _error('Must be a list.', node.span); - - // TODO(nweiz): Remove this when sdk#31384 is fixed. - throw "Unreachable"; } /// Runs [fn] and wraps any [FormatException] it throws in a diff --git a/lib/src/utils.dart b/lib/src/utils.dart index 88722df84..d9d774649 100644 --- a/lib/src/utils.dart +++ b/lib/src/utils.dart @@ -9,6 +9,7 @@ import 'dart:io'; import 'dart:math' as math; import "package:crypto/crypto.dart" as crypto; +import 'package:meta/meta.dart'; import 'package:path/path.dart' as path; import "package:stack_trace/stack_trace.dart"; @@ -725,6 +726,7 @@ String yamlToString(data) { } /// Throw a [ApplicationException] with [message]. +@alwaysThrows void fail(String message, [innerError, StackTrace innerTrace]) { if (innerError != null) { throw new WrappedException(message, innerError, innerTrace); diff --git a/test/descriptor_server.dart b/test/descriptor_server.dart index a5ddf09db..f438cf710 100644 --- a/test/descriptor_server.dart +++ b/test/descriptor_server.dart @@ -96,7 +96,6 @@ class DescriptorServer { _server.mount((request) { fail("The HTTP server received an unexpected request:\n" "${request.method} ${request.requestedUri}"); - return new shelf.Response.forbidden(null); }); addTearDown(() => _server.close()); }