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

Side by Side Diff: runtime/vm/exceptions.h

Issue 340203003: Cleanup of error and warning reporting. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 | « runtime/vm/compiler.cc ('k') | runtime/vm/exceptions.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) 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"
10 9
11 namespace dart { 10 namespace dart {
12 11
13 // Forward declarations. 12 // Forward declarations.
13 class Array;
14 class Class; 14 class Class;
15 class DartFrameIterator; 15 class DartFrameIterator;
16 class Error; 16 class Error;
17 class Instance; 17 class Instance;
18 class Object; 18 class Object;
19 class RawInstance; 19 class RawInstance;
20 class RawObject;
20 class RawScript; 21 class RawScript;
21 class RawStacktrace; 22 class RawStacktrace;
22 class RawObject; 23 class RawString;
23 class Script; 24 class Script;
24 class StackFrame; 25 class StackFrame;
25 class String; 26 class String;
26 27
27 class Exceptions : AllStatic { 28 class Exceptions : AllStatic {
28 public: 29 public:
29 static const char* kCastErrorDstName; 30 static const char* kCastErrorDstName;
30 31
31 static void Throw(Isolate* isolate, const Instance& exception); 32 static void Throw(Isolate* isolate, const Instance& exception);
32 static void ReThrow(Isolate* isolate, 33 static void ReThrow(Isolate* isolate,
33 const Instance& exception, 34 const Instance& exception,
34 const Instance& stacktrace); 35 const Instance& stacktrace);
35 static void PropagateError(const Error& error); 36 static void PropagateError(const Error& error);
36 37
37 // Report a Javascript compatibility warning at the call site given by 38 // Helpers to create and throw errors.
38 // caller_frame. Note that a JavascriptCompatibilityError is thrown
39 // if --warning_as_error is specified.
40 // Also calls TraceJSWarningV below.
41 static void JSWarning(StackFrame* caller_frame, const char* format, ...)
42 PRINTF_ATTRIBUTE(2, 3);
43
44 // Emit a Javascript compatibility warning to the current trace buffer.
45 static void TraceJSWarningF(const Script& script, intptr_t token_pos,
46 const char* format, ...) PRINTF_ATTRIBUTE(3, 4);
47 static void TraceJSWarningV(const Script& script, intptr_t token_pos,
48 const char* format, va_list args);
49
50 static RawStacktrace* CurrentStacktrace(); 39 static RawStacktrace* CurrentStacktrace();
51
52 // Helpers to create and throw errors.
53 static RawScript* GetCallerScript(DartFrameIterator* iterator); 40 static RawScript* GetCallerScript(DartFrameIterator* iterator);
54 static RawInstance* NewInstance(const char* class_name); 41 static RawInstance* NewInstance(const char* class_name);
55 static void CreateAndThrowTypeError(intptr_t location, 42 static void CreateAndThrowTypeError(intptr_t location,
56 const String& src_type_name, 43 const String& src_type_name,
57 const String& dst_type_name, 44 const String& dst_type_name,
58 const String& dst_name, 45 const String& dst_name,
59 const String& error_msg); 46 const String& error_msg);
60 47
61 enum ExceptionType { 48 enum ExceptionType {
62 kNone, 49 kNone,
(...skipping 15 matching lines...) Expand all
78 kType, 65 kType,
79 kFallThrough, 66 kFallThrough,
80 kAbstractClassInstantiation, 67 kAbstractClassInstantiation,
81 kMirroredCompilationError, 68 kMirroredCompilationError,
82 }; 69 };
83 70
84 static void ThrowByType(ExceptionType type, const Array& arguments); 71 static void ThrowByType(ExceptionType type, const Array& arguments);
85 static void ThrowOOM(); 72 static void ThrowOOM();
86 static void ThrowStackOverflow(); 73 static void ThrowStackOverflow();
87 static void ThrowArgumentError(const Instance& arg); 74 static void ThrowArgumentError(const Instance& arg);
75 static void ThrowJavascriptCompatibilityError(const char* msg);
88 76
89 // Returns a RawInstance if the exception is successfully created, 77 // Returns a RawInstance if the exception is successfully created,
90 // otherwise returns a RawError. 78 // otherwise returns a RawError.
91 static RawObject* Create(ExceptionType type, const Array& arguments); 79 static RawObject* Create(ExceptionType type, const Array& arguments);
92 80
93 private: 81 private:
94 DISALLOW_COPY_AND_ASSIGN(Exceptions); 82 DISALLOW_COPY_AND_ASSIGN(Exceptions);
95 }; 83 };
96 84
97 } // namespace dart 85 } // namespace dart
98 86
99 #endif // VM_EXCEPTIONS_H_ 87 #endif // VM_EXCEPTIONS_H_
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/exceptions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698