Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/integration/only_throw_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void main() {
"throw 'hello world!'; // LINT",
'throw null; // LINT',
'throw 7; // LINT',
'throw new Object(); // LINT',
'throw Object(); // LINT',
'throw returnString(); // LINT',
'throw error; // LINT',
'1 file analyzed, 6 issues found, in'
Expand Down
17 changes: 8 additions & 9 deletions test_data/integration/only_throw_errors/only_throw_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ void throwNumber() {
}

void throwObject() {
throw new Object(); // LINT
throw Object(); // LINT
}

void throwError() {
throw new Error(); // OK
throw Error(); // OK
}

void throwDynamicPrebuiltError() {
Expand All @@ -32,17 +32,17 @@ void throwDynamicPrebuiltError() {
}

void throwStaticPrebuiltError() {
Error error = new Error();
Error error = Error();
throw error; // OK
}

void throwArgumentError() {
Error error = new ArgumentError('oh!');
Error error = ArgumentError('oh!');
throw error; // OK
}

void throwException() {
Exception exception = new Exception('oh!');
Exception exception = Exception('oh!');
throw exception; // OK
}

Expand All @@ -56,18 +56,17 @@ void throwExceptionFromFunction() {
throw returnException();
}

Exception returnException() => new Exception('oh!');
Exception returnException() => Exception('oh!');

// TODO: Even though in the test this does not get linted, it does while
// analyzing the SDK code. Find out why.
dynamic noSuchMethod(Invocation invocation) {
throw new NoSuchMethodError(new Object(), invocation.memberName,
invocation.positionalArguments, invocation.namedArguments);
throw NoSuchMethodError.withInvocation(Object(), invocation);
}

class Err extends Object with Exception {
static throws() {
throw new Err(); // OK
throw Err(); // OK
}
}

Expand Down