Skip to content
Open
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
8 changes: 8 additions & 0 deletions pkgs/appengine/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.13.13-wip

* Rename error classes to use the `Exception` suffix
(`AppEngineException`, `NetworkException`, `ProtocolException`,
`ServiceException`, `ApplicationException`) to follow Dart conventions for
types implementing `Exception`. The old `*Error` names remain available as
deprecated type aliases, so this change is non-breaking.

## 0.13.12

* Upgrade dependency `package:gcloud` to `^0.9.0`.
Expand Down
46 changes: 30 additions & 16 deletions pkgs/appengine/lib/src/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,61 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.


import 'dart:io';

class AppEngineError implements Exception {
class AppEngineException implements Exception {
final String message;

const AppEngineError(this.message);
const AppEngineException(this.message);

@override
String toString() => 'AppEngineException: $message';
}

class NetworkError extends AppEngineError implements IOException {
NetworkError(super.message);
class NetworkException extends AppEngineException implements IOException {
NetworkException(super.message);

@override
String toString() => 'NetworkError: $message';
String toString() => 'NetworkException: $message';
}

class ProtocolError extends AppEngineError implements IOException {
static const ProtocolError INVALID_RESPONSE =
ProtocolError('Invalid response');
class ProtocolException extends AppEngineException implements IOException {
static const ProtocolException INVALID_RESPONSE =
ProtocolException('Invalid response');

const ProtocolError(super.message);
const ProtocolException(super.message);

@override
String toString() => 'ProtocolError: $message';
String toString() => 'ProtocolException: $message';
}

class ServiceError extends AppEngineError {
class ServiceException extends AppEngineException {
final String serviceName;

ServiceError(super.message, {this.serviceName = 'ServiceError'});
ServiceException(super.message, {this.serviceName = 'ServiceException'});

@override
String toString() => '$serviceName: $message';
}

class ApplicationError extends AppEngineError {
ApplicationError(super.message);
class ApplicationException extends AppEngineException {
ApplicationException(super.message);

@override
String toString() => 'ApplicationError: $message';
String toString() => 'ApplicationException: $message';
}

@Deprecated('Use AppEngineException instead')
typedef AppEngineError = AppEngineException;

@Deprecated('Use NetworkException instead')
typedef NetworkError = NetworkException;

@Deprecated('Use ProtocolException instead')
typedef ProtocolError = ProtocolException;

@Deprecated('Use ServiceException instead')
typedef ServiceError = ServiceException;

@Deprecated('Use ApplicationException instead')
typedef ApplicationError = ApplicationException;
3 changes: 2 additions & 1 deletion pkgs/appengine/lib/src/grpc_api_impl/datastore_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ class _Codec {
} else if (part.hasId()) {
id = part.id.toInt();
} else {
throw const errors.ProtocolError('Neither name nor id present in Key.');
throw const errors.ProtocolException(
'Neither name nor id present in Key.');
}
keyElements[i] = raw.KeyElement(part.kind, id);
}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/appengine/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: appengine
version: 0.13.12
version: 0.13.13-wip
description: >-
Support for using Dart as a custom runtime on Google App Engine Flexible
Environment.
Expand Down
10 changes: 5 additions & 5 deletions pkgs/appengine/test/utils/error_matchers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import 'package:test/test.dart';
import 'package:appengine/src/errors.dart';
import 'package:gcloud/datastore.dart' as datastore;

const isNetworkError = TypeMatcher<NetworkError>();
const isProtocolError = TypeMatcher<ProtocolError>();
const isServiceError = TypeMatcher<ServiceError>();
const isApplicationError = TypeMatcher<AppEngineError>();
const isAppEngineApplicationError = TypeMatcher<ApplicationError>();
const isNetworkError = TypeMatcher<NetworkException>();
const isProtocolError = TypeMatcher<ProtocolException>();
const isServiceError = TypeMatcher<ServiceException>();
const isApplicationError = TypeMatcher<AppEngineException>();
const isAppEngineApplicationError = TypeMatcher<ApplicationException>();

const isDatastoreApplicationError = TypeMatcher<datastore.ApplicationError>();
const isTransactionAbortedError =
Expand Down