Skip to content
This repository was archived by the owner on Feb 22, 2023. 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

export 'src/errors/errors.dart';
export 'src/in_app_purchase_platform.dart';
export 'src/in_app_purchase_platform_addition.dart';
export 'src/in_app_purchase_platform_addition_provider.dart';
Expand Down
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';
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)';
}
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)');
});
}