forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add InAppPurchaseException to platform interface (flutter#3852)
- Loading branch information
1 parent
e11179d
commit d3b9711
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
packages/in_app_purchase/in_app_purchase_platform_interface/lib/src/errors/errors.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
export 'errors.dart'; |
27 changes: 27 additions & 0 deletions
27
...purchase/in_app_purchase_platform_interface/lib/src/errors/in_app_purchase_exception.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
/// Thrown to indicate that an action failed while interacting with the | ||
/// in_app_purchase plugin. | ||
class InAppPurchaseException implements Exception { | ||
/// Creates a [InAppPurchaseException] with the specified source and error | ||
/// [code] and optional [message]. | ||
InAppPurchaseException({ | ||
required this.source, | ||
required this.code, | ||
this.message, | ||
}) : assert(code != null); | ||
|
||
/// An error code. | ||
final String code; | ||
|
||
/// A human-readable error message, possibly null. | ||
final String? message; | ||
|
||
/// Which source is the error on. | ||
final String source; | ||
|
||
@override | ||
String toString() => 'InAppPurchaseException($code, $message, $source)'; | ||
} |
23 changes: 23 additions & 0 deletions
23
...se/in_app_purchase_platform_interface/test/src/errors/in_app_purchase_exception_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:in_app_purchase_platform_interface/src/errors/in_app_purchase_exception.dart'; | ||
|
||
void main() { | ||
test('toString: Should return a description of the exception', () { | ||
final InAppPurchaseException exception = InAppPurchaseException( | ||
code: 'error_code', | ||
message: 'dummy message', | ||
source: 'dummy_source', | ||
); | ||
|
||
// Act | ||
final String actual = exception.toString(); | ||
|
||
// Assert | ||
expect(actual, | ||
'InAppPurchaseException(error_code, dummy message, dummy_source)'); | ||
}); | ||
} |