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

Side by Side Diff: pkg/docgen/lib/src/generator.dart

Issue 270993002: Added error handling and a better error message if we fail to write output in docgen. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library docgen.generator; 5 library docgen.generator;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 /// Writes [text] to a file in the output directory. 130 /// Writes [text] to a file in the output directory.
131 void _writeToFile(String text, String filename) { 131 void _writeToFile(String text, String filename) {
132 if (text == null) return; 132 if (text == null) return;
133 133
134 var filePath = path.join(_outputDirectory, filename); 134 var filePath = path.join(_outputDirectory, filename);
135 135
136 var parentDir = new Directory(path.dirname(filePath)); 136 var parentDir = new Directory(path.dirname(filePath));
137 if (!parentDir.existsSync()) parentDir.createSync(recursive: true); 137 if (!parentDir.existsSync()) parentDir.createSync(recursive: true);
138 138
139 new File(filePath) 139 try {
140 .writeAsStringSync(text, mode: FileMode.WRITE); 140 new File(filePath)
141 .writeAsStringSync(text, mode: FileMode.WRITE);
142 } on FileSystemException catch (e) {
143 print('Failed to write to the path $filePath. Do you have write '
144 'permissions to that directory? If not, please specifi a different '
kevmoo 2014/05/09 00:24:02 specify
145 'output directory using the --out option.');
146 exit(1);
147 }
141 } 148 }
142 149
143 /// Resolve all the links in the introductory comments for a given library or 150 /// Resolve all the links in the introductory comments for a given library or
144 /// package as specified by [filename]. 151 /// package as specified by [filename].
145 String _readIntroductionFile(String fileName, bool includeSdk) { 152 String _readIntroductionFile(String fileName, bool includeSdk) {
146 var linkResolver = (name) => globalFixReference(name); 153 var linkResolver = (name) => globalFixReference(name);
147 var defaultText = includeSdk ? _DEFAULT_SDK_INTRODUCTION : ''; 154 var defaultText = includeSdk ? _DEFAULT_SDK_INTRODUCTION : '';
148 var introText = defaultText; 155 var introText = defaultText;
149 if (fileName.isNotEmpty) { 156 if (fileName.isNotEmpty) {
150 var introFile = new File(fileName); 157 var introFile = new File(fileName);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 * [Samples](http://www.dartlang.org/samples/) 462 * [Samples](http://www.dartlang.org/samples/)
456 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn ing/contents/ch03.html) 463 * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-runn ing/contents/ch03.html)
457 464
458 This API reference is automatically generated from the source code in the 465 This API reference is automatically generated from the source code in the
459 [Dart project](https://code.google.com/p/dart/). 466 [Dart project](https://code.google.com/p/dart/).
460 If you'd like to contribute to this documentation, see 467 If you'd like to contribute to this documentation, see
461 [Contributing](https://code.google.com/p/dart/wiki/Contributing) 468 [Contributing](https://code.google.com/p/dart/wiki/Contributing)
462 and 469 and
463 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume ntation). 470 [Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocume ntation).
464 """; 471 """;
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