Jens Geyer | 56e5b9b | 2015-10-09 22:01:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | |
| 20 | #import "TProtocol.h" |
| 21 | |
| 22 | extern NSString *TApplicationErrorDomain; |
| 23 | |
| 24 | typedef NS_ENUM (int, TApplicationError) { |
| 25 | TApplicationErrorUnknown = 0, |
| 26 | TApplicationErrorUnknownMethod = 1, |
| 27 | TApplicationErrorInvalidMessageType = 2, |
| 28 | TApplicationErrorWrongMethodName = 3, |
| 29 | TApplicationErrorBadSequenceId = 4, |
| 30 | TApplicationErrorMissingResult = 5, |
| 31 | TApplicationErrorInternalError = 6, |
| 32 | TApplicationErrorProtocolError = 7, |
| 33 | TApplicationErrorInvalidTransform = 8, |
| 34 | TApplicationErrorInvalidProtocol = 9, |
| 35 | TApplicationErrorUnsupportedClientType = 10, |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | extern NSString *TApplicationErrorNameKey; |
| 40 | extern NSString *TApplicationErrorReasonKey; |
| 41 | extern NSString *TApplicationErrorMethodKey; |
| 42 | |
| 43 | |
| 44 | @interface NSError (TApplicationError) |
| 45 | |
| 46 | @property (readonly, copy) NSString *name; |
| 47 | @property (readonly, copy) NSString *reason; |
| 48 | |
| 49 | +(instancetype) errorWithType:(TApplicationError)type reason:(NSString *)reason; |
| 50 | |
| 51 | +(instancetype) read:(id<TProtocol>)protocol; |
| 52 | |
| 53 | -(BOOL) write:(id<TProtocol>)outProtocol error:(NSError *__autoreleasing *)error; |
| 54 | |
| 55 | @end |