| 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 #include "bin/dartutils.h" | 5 #include "bin/dartutils.h" |
| 6 | 6 |
| 7 #include "bin/extensions.h" | 7 #include "bin/extensions.h" |
| 8 #include "bin/directory.h" | 8 #include "bin/directory.h" |
| 9 #include "bin/file.h" | 9 #include "bin/file.h" |
| 10 #include "bin/io_buffer.h" | 10 #include "bin/io_buffer.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 args[1] = os_error; | 559 args[1] = os_error; |
| 560 return Dart_New(clazz, Dart_Null(), 2, args); | 560 return Dart_New(clazz, Dart_Null(), 2, args); |
| 561 } | 561 } |
| 562 | 562 |
| 563 | 563 |
| 564 Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url, | 564 Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url, |
| 565 const char* exception_name, | 565 const char* exception_name, |
| 566 const char* message) { | 566 const char* message) { |
| 567 // Create a Dart Exception object with a message. | 567 // Create a Dart Exception object with a message. |
| 568 Dart_Handle clazz = GetDartClass(library_url, exception_name); | 568 Dart_Handle clazz = GetDartClass(library_url, exception_name); |
| 569 Dart_Handle args[1]; | 569 if (message != NULL) { |
| 570 args[0] = NewString(message); | 570 Dart_Handle args[1]; |
| 571 return Dart_New(clazz, Dart_Null(), 1, args); | 571 args[0] = NewString(message); |
| 572 return Dart_New(clazz, Dart_Null(), 1, args); |
| 573 } else { |
| 574 return Dart_New(clazz, Dart_Null(), 0, NULL); |
| 575 } |
| 572 } | 576 } |
| 573 | 577 |
| 574 | 578 |
| 575 Dart_Handle DartUtils::NewDartArgumentError(const char* message) { | 579 Dart_Handle DartUtils::NewDartArgumentError(const char* message) { |
| 576 return NewDartExceptionWithMessage(kCoreLibURL, | 580 return NewDartExceptionWithMessage(kCoreLibURL, |
| 577 "ArgumentError", | 581 "ArgumentError", |
| 578 message); | 582 message); |
| 579 } | 583 } |
| 580 | 584 |
| 581 | 585 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 new CObjectString(CObject::NewString(os_error->message())); | 752 new CObjectString(CObject::NewString(os_error->message())); |
| 749 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); | 753 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); |
| 750 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); | 754 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); |
| 751 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); | 755 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); |
| 752 result->SetAt(2, error_message); | 756 result->SetAt(2, error_message); |
| 753 return result; | 757 return result; |
| 754 } | 758 } |
| 755 | 759 |
| 756 } // namespace bin | 760 } // namespace bin |
| 757 } // namespace dart | 761 } // namespace dart |
| OLD | NEW |