Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Side by Side Diff: lib/src/barback/barback_server.dart

Issue 1895423002: Don't assign to final 'trace' parameter in catch clause. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/pub.git@master
Patch Set: Rebase to most recent pub Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
10 import "package:crypto/crypto.dart"; 10 import "package:crypto/crypto.dart";
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // implicitly support that too. This follows Apache's behavior. 128 // implicitly support that too. This follows Apache's behavior.
129 logRequest(request, "302 Redirect to /${request.url}/"); 129 logRequest(request, "302 Redirect to /${request.url}/");
130 return new shelf.Response.found('/${request.url}/'); 130 return new shelf.Response.found('/${request.url}/');
131 }).catchError((newError, newTrace) { 131 }).catchError((newError, newTrace) {
132 // If we find neither the original file or the index, we should report 132 // If we find neither the original file or the index, we should report
133 // the error about the original to the user. 133 // the error about the original to the user.
134 throw newError is AssetNotFoundException ? error : newError; 134 throw newError is AssetNotFoundException ? error : newError;
135 }); 135 });
136 }).catchError((error, trace) { 136 }).catchError((error, trace) {
137 if (error is! AssetNotFoundException) { 137 if (error is! AssetNotFoundException) {
138 trace = new Chain.forTrace(trace); 138 var chain = new Chain.forTrace(trace);
139 logRequest(request, "$error\n$trace"); 139 logRequest(request, "$error\n$chain");
140 140
141 addError(error, trace); 141 addError(error, chain);
142 close(); 142 close();
143 return new shelf.Response.internalServerError(); 143 return new shelf.Response.internalServerError();
144 } 144 }
145 145
146 addResult(new BarbackServerResult._failure(request.url, id, error)); 146 addResult(new BarbackServerResult._failure(request.url, id, error));
147 return notFound(request, asset: id); 147 return notFound(request, asset: id);
148 }).then((response) { 148 }).then((response) {
149 // Allow requests of any origin to access "pub serve". This is useful for 149 // Allow requests of any origin to access "pub serve". This is useful for
150 // running "pub serve" in parallel with another development server. Since 150 // running "pub serve" in parallel with another development server. Since
151 // "pub serve" is only used as a development server and doesn't require 151 // "pub serve" is only used as a development server and doesn't require
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } catch (error, trace) { 190 } catch (error, trace) {
191 addResult(new BarbackServerResult._failure(request.url, asset.id, error)); 191 addResult(new BarbackServerResult._failure(request.url, asset.id, error));
192 192
193 // If we couldn't read the asset, handle the error gracefully. 193 // If we couldn't read the asset, handle the error gracefully.
194 if (error is FileSystemException) { 194 if (error is FileSystemException) {
195 // Assume this means the asset was a file-backed source asset 195 // Assume this means the asset was a file-backed source asset
196 // and we couldn't read it, so treat it like a missing asset. 196 // and we couldn't read it, so treat it like a missing asset.
197 return notFound(request, error: error.toString(), asset: asset.id); 197 return notFound(request, error: error.toString(), asset: asset.id);
198 } 198 }
199 199
200 trace = new Chain.forTrace(trace); 200 var chain = new Chain.forTrace(trace);
201 logRequest(request, "$error\n$trace"); 201 logRequest(request, "$error\n$chain");
202 202
203 // Otherwise, it's some internal error. 203 // Otherwise, it's some internal error.
204 return new shelf.Response.internalServerError(body: error.toString()); 204 return new shelf.Response.internalServerError(body: error.toString());
205 } 205 }
206 } 206 }
207 } 207 }
208 208
209 /// The result of the server handling a URL. 209 /// The result of the server handling a URL.
210 /// 210 ///
211 /// Only requests for which an asset was requested from barback will emit a 211 /// Only requests for which an asset was requested from barback will emit a
(...skipping 23 matching lines...) Expand all
235 : error = null, 235 : error = null,
236 isCached = false; 236 isCached = false;
237 237
238 BarbackServerResult._cached(this.url, this.id) 238 BarbackServerResult._cached(this.url, this.id)
239 : error = null, 239 : error = null,
240 isCached = true; 240 isCached = true;
241 241
242 BarbackServerResult._failure(this.url, this.id, this.error) 242 BarbackServerResult._failure(this.url, this.id, this.error)
243 : isCached = false; 243 : isCached = false;
244 } 244 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698