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

Side by Side Diff: tracing/tracing/base/unit.html

Issue 2996873002: Improve error message in tr.b.Unit.fromJSON (Closed)
Patch Set: Created 3 years, 4 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <!-- 2 <!--
3 Copyright 2015 The Chromium Authors. All rights reserved. 3 Copyright 2015 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be 4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file. 5 found in the LICENSE file.
6 --> 6 -->
7 7
8 <link rel="import" href="/tracing/base/event.html"> 8 <link rel="import" href="/tracing/base/event.html">
9 <link rel="import" href="/tracing/base/event_target.html"> 9 <link rel="import" href="/tracing/base/event_target.html">
10 <link rel="import" href="/tracing/base/iteration_helpers.html"> 10 <link rel="import" href="/tracing/base/iteration_helpers.html">
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 }; 227 };
228 228
229 Unit.byName = {}; 229 Unit.byName = {};
230 Unit.byJSONName = {}; 230 Unit.byJSONName = {};
231 231
232 Unit.fromJSON = function(object) { 232 Unit.fromJSON = function(object) {
233 const u = Unit.byJSONName[object]; 233 const u = Unit.byJSONName[object];
234 if (u) { 234 if (u) {
235 return u; 235 return u;
236 } 236 }
237 throw new Error('Unrecognized unit'); 237 throw new Error(`Unrecognized unit "${object}"`);
238 }; 238 };
239 239
240 /** 240 /**
241 * Define all combinations of a unit with isDelta and improvementDirection 241 * Define all combinations of a unit with isDelta and improvementDirection
242 * flags. For example, the following code: 242 * flags. For example, the following code:
243 * 243 *
244 * Unit.define({ 244 * Unit.define({
245 * baseUnitName: 'powerInWatts' 245 * baseUnitName: 'powerInWatts'
246 * baseJsonName: 'W' 246 * baseJsonName: 'W'
247 * formatSpec: { 247 * formatSpec: {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 maximumFractionDigits: 1 425 maximumFractionDigits: 1
426 } 426 }
427 }); 427 });
428 428
429 return { 429 return {
430 ImprovementDirection, 430 ImprovementDirection,
431 Unit, 431 Unit,
432 }; 432 };
433 }); 433 });
434 </script> 434 </script>
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