| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #ifndef VM_EXCEPTIONS_H_ | 5 #ifndef VM_EXCEPTIONS_H_ |
| 6 #define VM_EXCEPTIONS_H_ | 6 #define VM_EXCEPTIONS_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // Forward declarations. | 13 // Forward declarations. |
| 14 class Error; |
| 14 class Instance; | 15 class Instance; |
| 15 class Object; | 16 class Object; |
| 16 class RawInstance; | 17 class RawObject; |
| 17 | 18 |
| 18 class Exceptions : AllStatic { | 19 class Exceptions : AllStatic { |
| 19 public: | 20 public: |
| 20 static void Throw(const Instance& exception); | 21 static void Throw(const Instance& exception); |
| 21 static void ReThrow(const Instance& exception, const Instance& stacktrace); | 22 static void ReThrow(const Instance& exception, const Instance& stacktrace); |
| 23 static void PropagateError(const Object& obj); |
| 22 | 24 |
| 23 enum ExceptionType { | 25 enum ExceptionType { |
| 24 kIndexOutOfRange, | 26 kIndexOutOfRange, |
| 25 kIllegalArgument, | 27 kIllegalArgument, |
| 26 kNoSuchMethod, | 28 kNoSuchMethod, |
| 27 kClosureArgumentMismatch, | 29 kClosureArgumentMismatch, |
| 28 kObjectNotClosure, | 30 kObjectNotClosure, |
| 29 kBadNumberFormat, | 31 kBadNumberFormat, |
| 30 kStackOverflow, | 32 kStackOverflow, |
| 31 kOutOfMemory, | 33 kOutOfMemory, |
| 32 kWrongArgumentCount, | 34 kWrongArgumentCount, |
| 33 kInternalError, | 35 kInternalError, |
| 34 kNullPointer, | 36 kNullPointer, |
| 35 kIllegalJSRegExp, | 37 kIllegalJSRegExp, |
| 36 }; | 38 }; |
| 37 | 39 |
| 38 static void ThrowByType(ExceptionType type, | 40 static void ThrowByType(ExceptionType type, |
| 39 const GrowableArray<const Object*>& arguments); | 41 const GrowableArray<const Object*>& arguments); |
| 40 static RawInstance* Create(ExceptionType type, | 42 // Returns a RawInstance if the exception is successfully created, |
| 41 const GrowableArray<const Object*>& arguments); | 43 // otherwise returns a RawError. |
| 44 static RawObject* Create(ExceptionType type, |
| 45 const GrowableArray<const Object*>& arguments); |
| 42 | 46 |
| 43 private: | 47 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(Exceptions); | 48 DISALLOW_COPY_AND_ASSIGN(Exceptions); |
| 45 }; | 49 }; |
| 46 | 50 |
| 47 } // namespace dart | 51 } // namespace dart |
| 48 | 52 |
| 49 #endif // VM_EXCEPTIONS_H_ | 53 #endif // VM_EXCEPTIONS_H_ |
| OLD | NEW |