OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library error_matchers; |
| 6 |
| 7 import 'package:unittest/unittest.dart'; |
| 8 |
| 9 import 'package:appengine/api/errors.dart'; |
| 10 import 'package:gcloud/datastore.dart' as datastore; |
| 11 |
| 12 import 'package:memcache/memcache.dart' as memcache; |
| 13 |
| 14 class _NetworkError extends TypeMatcher { |
| 15 const _NetworkError() : super("NetworkError"); |
| 16 bool matches(item, Map matchState) => item is NetworkError; |
| 17 } |
| 18 |
| 19 class _ProtocolError extends TypeMatcher { |
| 20 const _ProtocolError() : super("ProtocolError"); |
| 21 bool matches(item, Map matchState) => item is ProtocolError; |
| 22 } |
| 23 |
| 24 class _ServiceError extends TypeMatcher { |
| 25 const _ServiceError() : super("ServiceError"); |
| 26 bool matches(item, Map matchState) => item is ServiceError; |
| 27 } |
| 28 |
| 29 class _ApplicationError extends TypeMatcher { |
| 30 const _ApplicationError() : super("ApplicationError"); |
| 31 bool matches(item, Map matchState) => item is datastore.ApplicationError; |
| 32 } |
| 33 |
| 34 class _AppEngineApplicationError extends TypeMatcher { |
| 35 const _AppEngineApplicationError() : super("ApplicationError"); |
| 36 bool matches(item, Map matchState) => item is ApplicationError; |
| 37 } |
| 38 |
| 39 class _TransactionAbortedError extends TypeMatcher { |
| 40 const _TransactionAbortedError() : super("TransactionAbortedError"); |
| 41 bool matches(item, Map matchState) |
| 42 => item is datastore.TransactionAbortedError; |
| 43 } |
| 44 |
| 45 class _NeedIndexError extends TypeMatcher { |
| 46 const _NeedIndexError() : super("NeedIndexError"); |
| 47 bool matches(item, Map matchState) => item is datastore.NeedIndexError; |
| 48 } |
| 49 |
| 50 class _TimeoutError extends TypeMatcher { |
| 51 const _TimeoutError() : super("TimeoutError"); |
| 52 bool matches(item, Map matchState) => item is datastore.TimeoutError; |
| 53 } |
| 54 |
| 55 class _MemcacheError extends TypeMatcher { |
| 56 const _MemcacheError() : super("MemcacheError"); |
| 57 bool matches(item, Map matchState) => item is memcache.MemcacheError; |
| 58 } |
| 59 |
| 60 class _MemcacheNotStoredError extends TypeMatcher { |
| 61 const _MemcacheNotStoredError() : super("NotStoredError"); |
| 62 bool matches(item, Map matchState) => item is memcache.NotStoredError; |
| 63 } |
| 64 |
| 65 |
| 66 class _IntMatcher extends TypeMatcher { |
| 67 const _IntMatcher() : super("IntMatcher"); |
| 68 bool matches(item, Map matchState) => item is int; |
| 69 } |
| 70 |
| 71 const isNetworkError = const _NetworkError(); |
| 72 const isProtocolError = const _ProtocolError(); |
| 73 const isServiceError = const _ServiceError(); |
| 74 const isApplicationError = const _ApplicationError(); |
| 75 const isAppEngineApplicationError = const _AppEngineApplicationError(); |
| 76 |
| 77 const isTransactionAbortedError = const _TransactionAbortedError(); |
| 78 const isNeedIndexError = const _NeedIndexError(); |
| 79 const isTimeoutError = const _TimeoutError(); |
| 80 |
| 81 const isMemcacheError = const _MemcacheError(); |
| 82 const isMemcacheNotStored = const _MemcacheNotStoredError(); |
| 83 |
| 84 const isInt = const _IntMatcher(); |
OLD | NEW |