| 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 #include "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
| 6 | 6 |
| 7 #include "platform/address_sanitizer.h" | 7 #include "platform/address_sanitizer.h" |
| 8 | 8 |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 const Array& args = Array::Handle(Array::New(1)); | 559 const Array& args = Array::Handle(Array::New(1)); |
| 560 args.SetAt(0, arg); | 560 args.SetAt(0, arg); |
| 561 Exceptions::ThrowByType(Exceptions::kArgument, args); | 561 Exceptions::ThrowByType(Exceptions::kArgument, args); |
| 562 } | 562 } |
| 563 | 563 |
| 564 | 564 |
| 565 void Exceptions::ThrowRangeError(const char* argument_name, | 565 void Exceptions::ThrowRangeError(const char* argument_name, |
| 566 const Integer& argument_value, | 566 const Integer& argument_value, |
| 567 intptr_t expected_from, | 567 intptr_t expected_from, |
| 568 intptr_t expected_to) { | 568 intptr_t expected_to) { |
| 569 const String& error = String::Handle(String::NewFormatted( | 569 const Array& args = Array::Handle(Array::New(4)); |
| 570 "%s (%s) must be in the range [%" Pd "..%" Pd ")", | 570 args.SetAt(0, argument_value); |
| 571 argument_name, | 571 args.SetAt(1, Integer::Handle(Integer::New(expected_from))); |
| 572 argument_value.ToCString(), | 572 args.SetAt(2, Integer::Handle(Integer::New(expected_to))); |
| 573 expected_from, | 573 args.SetAt(3, String::Handle(String::New(argument_name))); |
| 574 expected_to)); | 574 Exceptions::ThrowByType(Exceptions::kRangeRange, args); |
| 575 | |
| 576 const Array& args = Array::Handle(Array::New(1)); | |
| 577 args.SetAt(0, error); | |
| 578 Exceptions::ThrowByType(Exceptions::kRange, args); | |
| 579 } | 575 } |
| 580 | 576 |
| 581 | 577 |
| 582 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { | 578 RawObject* Exceptions::Create(ExceptionType type, const Array& arguments) { |
| 583 Library& library = Library::Handle(); | 579 Library& library = Library::Handle(); |
| 584 const String* class_name = NULL; | 580 const String* class_name = NULL; |
| 585 const String* constructor_name = &Symbols::Dot(); | 581 const String* constructor_name = &Symbols::Dot(); |
| 586 switch (type) { | 582 switch (type) { |
| 587 case kNone: | 583 case kNone: |
| 588 case kStackOverflow: | 584 case kStackOverflow: |
| 589 case kOutOfMemory: | 585 case kOutOfMemory: |
| 590 UNREACHABLE(); | 586 UNREACHABLE(); |
| 591 break; | 587 break; |
| 592 case kRange: | 588 case kRange: |
| 593 library = Library::CoreLibrary(); | 589 library = Library::CoreLibrary(); |
| 594 class_name = &Symbols::RangeError(); | 590 class_name = &Symbols::RangeError(); |
| 595 break; | 591 break; |
| 592 case kRangeRange: |
| 593 library = Library::CoreLibrary(); |
| 594 class_name = &Symbols::RangeError(); |
| 595 constructor_name = &Symbols::DotRange(); |
| 596 break; |
| 596 case kArgument: | 597 case kArgument: |
| 597 library = Library::CoreLibrary(); | 598 library = Library::CoreLibrary(); |
| 598 class_name = &Symbols::ArgumentError(); | 599 class_name = &Symbols::ArgumentError(); |
| 599 break; | 600 break; |
| 600 case kNoSuchMethod: | 601 case kNoSuchMethod: |
| 601 library = Library::CoreLibrary(); | 602 library = Library::CoreLibrary(); |
| 602 class_name = &Symbols::NoSuchMethodError(); | 603 class_name = &Symbols::NoSuchMethodError(); |
| 603 constructor_name = &Symbols::DotWithType(); | 604 constructor_name = &Symbols::DotWithType(); |
| 604 break; | 605 break; |
| 605 case kFormat: | 606 case kFormat: |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 | 670 |
| 670 // Throw JavascriptCompatibilityError exception. | 671 // Throw JavascriptCompatibilityError exception. |
| 671 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { | 672 void Exceptions::ThrowJavascriptCompatibilityError(const char* msg) { |
| 672 const Array& exc_args = Array::Handle(Array::New(1)); | 673 const Array& exc_args = Array::Handle(Array::New(1)); |
| 673 const String& msg_str = String::Handle(String::New(msg)); | 674 const String& msg_str = String::Handle(String::New(msg)); |
| 674 exc_args.SetAt(0, msg_str); | 675 exc_args.SetAt(0, msg_str); |
| 675 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); | 676 Exceptions::ThrowByType(Exceptions::kJavascriptCompatibilityError, exc_args); |
| 676 } | 677 } |
| 677 | 678 |
| 678 } // namespace dart | 679 } // namespace dart |
| OLD | NEW |