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

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

Issue 19172002: Revert "Cleanup VM error handling." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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));
782 Dart_Handle args[2]; 781 Dart_Handle args[2];
783 args[0] = NewString(os_error->message()); 782 args[0] = NewString(os_error->message());
784 args[1] = Dart_NewInteger(os_error->code()); 783 args[1] = Dart_NewInteger(os_error->code());
785 return Dart_New(type, Dart_Null(), 2, args); 784 return Dart_New(type, Dart_Null(), 2, args);
786 } 785 }
787 786
788 787
789 Dart_Handle DartUtils::NewDartExceptionWithOSError(const char* library_url, 788 Dart_Handle DartUtils::NewDartExceptionWithOSError(const char* library_url,
790 const char* exception_name, 789 const char* exception_name,
791 const char* message, 790 const char* message,
792 Dart_Handle os_error) { 791 Dart_Handle os_error) {
793 // Create a Dart Exception object with a message and an OSError. 792 // Create a Dart Exception object with a message and an OSError.
794 Dart_Handle type = GetDartType(library_url, exception_name); 793 Dart_Handle type = GetDartType(library_url, exception_name);
795 ASSERT(!Dart_IsError(type));
796 Dart_Handle args[2]; 794 Dart_Handle args[2];
797 args[0] = NewString(message); 795 args[0] = NewString(message);
798 args[1] = os_error; 796 args[1] = os_error;
799 return Dart_New(type, Dart_Null(), 2, args); 797 return Dart_New(type, Dart_Null(), 2, args);
800 } 798 }
801 799
802 800
803 Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url, 801 Dart_Handle DartUtils::NewDartExceptionWithMessage(const char* library_url,
804 const char* exception_name, 802 const char* exception_name,
805 const char* message) { 803 const char* message) {
806 // Create a Dart Exception object with a message. 804 // Create a Dart Exception object with a message.
807 Dart_Handle type = GetDartType(library_url, exception_name); 805 Dart_Handle type = GetDartType(library_url, exception_name);
808 ASSERT(!Dart_IsError(type));
809 if (message != NULL) { 806 if (message != NULL) {
810 Dart_Handle args[1]; 807 Dart_Handle args[1];
811 args[0] = NewString(message); 808 args[0] = NewString(message);
812 return Dart_New(type, Dart_Null(), 1, args); 809 return Dart_New(type, Dart_Null(), 1, args);
813 } else { 810 } else {
814 return Dart_New(type, Dart_Null(), 0, NULL); 811 return Dart_New(type, Dart_Null(), 0, NULL);
815 } 812 }
816 } 813 }
817 814
818 815
819 Dart_Handle DartUtils::NewDartArgumentError(const char* message) { 816 Dart_Handle DartUtils::NewDartArgumentError(const char* message) {
820 return NewDartExceptionWithMessage(kCoreLibURL, 817 return NewDartExceptionWithMessage(kCoreLibURL,
821 "ArgumentError", 818 "ArgumentError",
822 message); 819 message);
823 } 820 }
824 821
825 822
826 Dart_Handle DartUtils::NewDartIOException(const char* exception_name, 823 Dart_Handle DartUtils::NewDartIOException(const char* exception_name,
827 const char* message, 824 const char* message,
828 Dart_Handle os_error) { 825 Dart_Handle os_error) {
829 // Create a dart:io exception object of the given type. 826 // Create a dart:io exception object of the given type.
830 return NewDartExceptionWithOSError(kIOLibURL, 827 return NewDartExceptionWithOSError(kIOLibURL,
831 exception_name, 828 exception_name,
832 message, 829 message,
833 os_error); 830 os_error);
834 } 831 }
835 832
836 833
837 Dart_Handle DartUtils::NewInternalError(const char* message) { 834 Dart_Handle DartUtils::NewInternalError(const char* message) {
838 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message); 835 return NewDartExceptionWithMessage(kCoreLibURL, "InternalError", message);
839 } 836 }
840 837
841 838
842 void DartUtils::SetOriginalWorkingDirectory() { 839 void DartUtils::SetOriginalWorkingDirectory() {
843 original_working_directory = Directory::Current(); 840 original_working_directory = Directory::Current();
844 } 841 }
845 842
846 843
847 // Statically allocated Dart_CObject instances for immutable 844 // Statically allocated Dart_CObject instances for immutable
848 // objects. As these will be used by different threads the use of 845 // objects. As these will be used by different threads the use of
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 new CObjectString(CObject::NewString(os_error->message())); 995 new CObjectString(CObject::NewString(os_error->message()));
999 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 996 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1000 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 997 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1001 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 998 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1002 result->SetAt(2, error_message); 999 result->SetAt(2, error_message);
1003 return result; 1000 return result;
1004 } 1001 }
1005 1002
1006 } // namespace bin 1003 } // namespace bin
1007 } // namespace dart 1004 } // 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