Line data Source code
1 : // Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file 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. 4 : 5 : /// A regular expression to match the exception prefix that some exceptions' 6 : /// [Object.toString] values contain. 7 0 : final _exceptionPrefix = RegExp(r'^([A-Z][a-zA-Z]*)?(Exception|Error): '); 8 : 9 : /// Get a string description of an exception. 10 : /// 11 : /// Many exceptions include the exception class name at the beginning of their 12 : /// [toString], so we remove that if it exists. 13 0 : String getErrorMessage(error) => 14 0 : error.toString().replaceFirst(_exceptionPrefix, '');