Files
sdk/runtime/lib/error.dart
T
regis@google.com dc895f3138 Rename class AssertError to AssertionError in the VM (fix issue 119).
Move VM specific tests to the correct tests directory.
Enable asserts in the VM when type checks are enabled.
Review URL: http://codereview.chromium.org//8294005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@460 260f80e4-7a28-3924-810f-c04153c831b5
2011-10-14 22:02:50 +00:00

57 lines
1.8 KiB
Dart

// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Errors are created and thrown by DartVM only.
// Changes here should also be reflected in corelib/error.dart as well
class AssertionError {
factory AssertionError._uninstantiable() {
throw const UnsupportedOperationException(
"AssertionError can only be allocated by the VM");
}
static throwNew(int assertionStart, int assertionEnd)
native "AssertionError_throwNew";
String toString() {
return "Failed assertion: '$failedAssertion' is not true " +
"in $url at line $line, column $column.";
}
final String failedAssertion;
final String url;
final int line;
final int column;
}
class TypeError extends AssertionError {
factory TypeError._uninstantiable() {
throw const UnsupportedOperationException(
"TypeError can only be allocated by the VM");
}
String toString() {
return "Failed type check: type $srcType is not assignable to type " +
"$dstType of $dstName in $url at line " +
"$line, column $column.";
}
final String srcType;
final String dstType;
final String dstName;
}
class FallThroughError {
factory FallThroughError._uninstantiable() {
throw const UnsupportedOperationException(
"FallThroughError can only be allocated by the VM");
}
static throwNew(int case_clause_pos) native "FallThroughError_throwNew";
String toString() {
return "Switch case fall-through in $url at line $line.";
}
final String url;
final int line;
}
class InternalError {
const InternalError(this._msg);
String toString() => "InternalError: '${_msg}'";
final String _msg;
}