Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: runtime/bin/dartutils.cc

Issue 18531003: Cleanup VM error handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/error.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 9
10 #include "platform/assert.h" 10 #include "platform/assert.h"
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 Dart_Handle DartUtils::NewDartOSError() { 771 Dart_Handle DartUtils::NewDartOSError() {
772 // Extract the current OS error. 772 // Extract the current OS error.
773 OSError os_error; 773 OSError os_error;
774 return NewDartOSError(&os_error); 774 return NewDartOSError(&os_error);
775 } 775 }
776 776
777 777
778 Dart_Handle DartUtils::NewDartOSError(OSError* os_error) { 778 Dart_Handle DartUtils::NewDartOSError(OSError* os_error) {
779 // Create a dart:io OSError object with the information retrieved from the OS. 779 // Create a dart:io OSError object with the information retrieved from the OS.
780 Dart_Handle type = GetDartType(kIOLibURL, "OSError"); 780 Dart_Handle type = GetDartType(kIOLibURL, "OSError");
781 ASSERT(!Dart_IsError(type));
781 Dart_Handle args[2]; 782 Dart_Handle args[2];
782 args[0] = NewString(os_error->message()); 783 args[0] = NewString(os_error->message());
783 args[1] = Dart_NewInteger(os_error->code()); 784 args[1] = Dart_NewInteger(os_error->code());
784 return Dart_New(type, Dart_Null(), 2, args); 785 return Dart_New(type, Dart_Null(), 2, args);
785 } 786 }
786 787
787 788
788 Dart_Handle DartUtils::NewDartExceptionWithOSError(const char* library_url, 789 Dart_Handle DartUtils::NewDartExceptionWithOSError(const char* library_url,
789 const char* exception_name, 790 const char* exception_name,
790 const char* message, 791 const char* message,
791 Dart_Handle os_error) { 792 Dart_Handle os_error) {
792 // Create a Dart Exception object with a message and an OSError. 793 // Create a Dart Exception object with a message and an OSError.
793 Dart_Handle type = GetDartType(library_url, exception_name); 794 Dart_Handle type = GetDartType(library_url, exception_name);
795 ASSERT(!Dart_IsError(type));
794 Dart_Handle args[2]; 796 Dart_Handle args[2];
795 args[0] = NewString(message); 797 args[0] = NewString(message);
796 args[1] = os_error; 798 args[1] = os_error;
797 return Dart_New(type, Dart_Null(), 2, args); 799 return Dart_New(type, Dart_Null(), 2, args);
798 } 800 }
799 801
800 802
801 Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url, 803 Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url,
802 const char* exception_name, 804 const char* exception_name,
803 const char* message) { 805 const char* message) {
804 // Create a Dart Exception object with a message. 806 // Create a Dart Exception object with a message.
805 Dart_Handle type = GetDartType(library_url, exception_name); 807 Dart_Handle type = GetDartType(library_url, exception_name);
808 ASSERT(!Dart_IsError(type));
806 if (message != NULL) { 809 if (message != NULL) {
807 Dart_Handle args[1]; 810 Dart_Handle args[1];
808 args[0] = NewString(message); 811 args[0] = NewString(message);
809 return Dart_New(type, Dart_Null(), 1, args); 812 return Dart_New(type, Dart_Null(), 1, args);
810 } else { 813 } else {
811 return Dart_New(type, Dart_Null(), 0, NULL); 814 return Dart_New(type, Dart_Null(), 0, NULL);
812 } 815 }
813 } 816 }
814 817
815 818
816 Dart_Handle DartUtils::NewDartArgumentError(const char* message) { 819 Dart_Handle DartUtils::NewDartArgumentError(const char* message) {
817 return NewDartExceptionWithMessage(kCoreLibURL, 820 return NewDartExceptionWithMessage(kCoreLibURL,
818 "ArgumentError", 821 "ArgumentError",
819 message); 822 message);
820 } 823 }
821 824
822 825
823 Dart_Handle DartUtils::NewDartIOException(const char* exception_name, 826 Dart_Handle DartUtils::NewDartIOException(const char* exception_name,
824 const char* message, 827 const char* message,
825 Dart_Handle os_error) { 828 Dart_Handle os_error) {
826 // Create a dart:io exception object of the given type. 829 // Create a dart:io exception object of the given type.
827 return NewDartExceptionWithOSError(kIOLibURL, 830 return NewDartExceptionWithOSError(kIOLibURL,
828 exception_name, 831 exception_name,
829 message, 832 message,
830 os_error); 833 os_error);
831 } 834 }
832 835
833 836
834 Dart_Handle DartUtils::NewInternalError(const char* message) { 837 Dart_Handle DartUtils::NewInternalError(const char* message) {
835 return NewDartExceptionWithMessage(kCoreLibURL, "InternalError", message); 838 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message);
836 } 839 }
837 840
838 841
839 void DartUtils::SetOriginalWorkingDirectory() { 842 void DartUtils::SetOriginalWorkingDirectory() {
840 original_working_directory = Directory::Current(); 843 original_working_directory = Directory::Current();
841 } 844 }
842 845
843 846
844 // Statically allocated Dart_CObject instances for immutable 847 // Statically allocated Dart_CObject instances for immutable
845 // objects. As these will be used by different threads the use of 848 // objects. As these will be used by different threads the use of
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 new CObjectString(CObject::NewString(os_error->message())); 998 new CObjectString(CObject::NewString(os_error->message()));
996 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 999 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
997 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1000 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
998 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1001 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
999 result->SetAt(2, error_message); 1002 result->SetAt(2, error_message);
1000 return result; 1003 return result;
1001 } 1004 }
1002 1005
1003 } // namespace bin 1006 } // namespace bin
1004 } // namespace dart 1007 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698