OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /// Generic utility functions. Stuff that should possibly be in core. | 5 /// Generic utility functions. Stuff that should possibly be in core. |
6 library pub.utils; | 6 library pub.utils; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import "dart:collection"; | 9 import "dart:collection"; |
10 import "dart:convert"; | 10 import "dart:convert"; |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 /// All the names of user-facing exceptions. | 706 /// All the names of user-facing exceptions. |
707 final _userFacingExceptions = new Set<String>.from([ | 707 final _userFacingExceptions = new Set<String>.from([ |
708 'ApplicationException', | 708 'ApplicationException', |
709 // Errors coming from the Dart analyzer are probably caused by syntax errors | 709 // Errors coming from the Dart analyzer are probably caused by syntax errors |
710 // in user code, so they're user-facing. | 710 // in user code, so they're user-facing. |
711 'AnalyzerError', 'AnalyzerErrorGroup', | 711 'AnalyzerError', 'AnalyzerErrorGroup', |
712 // An error spawning an isolate probably indicates a transformer with an | 712 // An error spawning an isolate probably indicates a transformer with an |
713 // invalid import. | 713 // invalid import. |
714 'IsolateSpawnException', | 714 'IsolateSpawnException', |
715 // TODO(nweiz): clean up the dart:io errors when issue 9955 is fixed. | 715 // TODO(nweiz): clean up the dart:io errors when issue 9955 is fixed. |
716 'DirectoryException', 'FileException', 'HttpException', 'HttpException', | 716 'FileSystemException', 'HttpException', 'HttpException', 'OSError', |
717 'LinkException', 'OSError', 'ProcessException', 'SocketException', | 717 'ProcessException', 'SocketException', 'WebSocketException' |
718 'WebSocketException' | |
719 ]); | 718 ]); |
720 | 719 |
721 /// Returns whether [error] is a user-facing error object. This includes both | 720 /// Returns whether [error] is a user-facing error object. This includes both |
722 /// [ApplicationException] and any dart:io errors. | 721 /// [ApplicationException] and any dart:io errors. |
723 bool isUserFacingException(error) { | 722 bool isUserFacingException(error) { |
724 if (error is CrossIsolateException) { | 723 if (error is CrossIsolateException) { |
725 return _userFacingExceptions.contains(error.type); | 724 return _userFacingExceptions.contains(error.type); |
726 } | 725 } |
727 | 726 |
728 // TODO(nweiz): unify this list with _userFacingExceptions when issue 5897 is | 727 // TODO(nweiz): unify this list with _userFacingExceptions when issue 5897 is |
729 // fixed. | 728 // fixed. |
730 return error is ApplicationException || | 729 return error is ApplicationException || |
731 error is AnalyzerError || | 730 error is AnalyzerError || |
732 error is AnalyzerErrorGroup || | 731 error is AnalyzerErrorGroup || |
733 error is IsolateSpawnException || | 732 error is IsolateSpawnException || |
734 error is DirectoryException || | 733 error is FileSystemException || |
735 error is FileException || | |
736 error is HttpException || | 734 error is HttpException || |
737 error is HttpException || | 735 error is HttpException || |
738 error is LinkException || | |
739 error is OSError || | 736 error is OSError || |
740 error is ProcessException || | 737 error is ProcessException || |
741 error is SocketException || | 738 error is SocketException || |
742 error is WebSocketException; | 739 error is WebSocketException; |
743 } | 740 } |
OLD | NEW |