TtsError.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // TtsError.h
  3. // cloud-tts-sdk-ios
  4. //
  5. // Created by dgw on 2022/1/10.
  6. //
  7. #ifndef TtsError_h
  8. #define TtsError_h
  9. #import <Foundation/Foundation.h>
  10. typedef NS_ENUM(NSInteger, TtsErrorCode) {
  11. TTS_ERROR_CODE_UNINITIALIZED = -100, //Engine uninitialized
  12. TTS_ERROR_CODE_GENERATE_SIGN_FAIL = -101, //generate sign failed
  13. TTS_ERROR_CODE_NETWORK_CONNECT_FAILED = 102, //network connect failed
  14. TTS_ERROR_CODE_DECODE_FAIL = -103, //JSON Response Parsing Error
  15. TTS_ERROR_CODE_SERVER_RESPONSE_ERROR = -104, //Server response error
  16. TTS_ERROR_CODE_CANCEL_FAILURE = -106, //Cancel failure,please try again later
  17. TTS_ERROR_CODE_OFFLINE_FAILURE = -107,//Offline synthesize failed, please check your text and VoiceType
  18. TTS_ERROR_CODE_OFFLINE_INIT_FAILURE = -108,//Offline engine initialization failed, please check resource files
  19. TTS_ERROR_CODE_OFFLINE_AUTH_FAILURE = -109,//Offline engine auth failure
  20. TTS_ERROR_CODE_OFFLINE_TEXT_TOO_LONG = -110, //Offline synthesize failed,text too long,MAX <= 1024 byte
  21. TTS_ERROR_CODE_OFFLINE_VOICE_AUTH_FAILURE = -111, //This voice not authorized, please change it
  22. TTS_ERROR_CODE_OFFLINE_NOSUPPORT = -900 //This SDK only supports online mode
  23. };
  24. /// 后端返回的错误信息
  25. @interface TtsServiceError : NSObject
  26. @property (nonatomic, copy) NSString* _Nullable err_code;
  27. @property (nonatomic, copy) NSString* _Nullable msg;
  28. @property (nonatomic, copy) NSString* _Nullable respose;
  29. +(instancetype _Nonnull)getTtsServiceError:(NSString *_Nullable)err_code ErrorMsg:(NSString* _Nullable)msg Respose:(NSString* _Nullable)respose;
  30. @end
  31. /// 错误信息类
  32. @interface TtsError : NSObject
  33. @property (nonatomic, assign) TtsErrorCode err_code; //错误码
  34. @property (nonatomic, copy, nullable) NSString* msg; //错误信息
  35. @property (nonatomic, copy, nullable) NSError * error; //系统抛出的错误信息(不一定有,可能为空)
  36. @property (nonatomic, strong ,nullable) TtsServiceError * serviceError;//服务器返回的错误信息(不一定有,可能为空)
  37. +(instancetype _Nonnull)getTtsError:(TtsErrorCode)err_code
  38. TtsServiceError:(TtsServiceError* _Nullable)serviceError
  39. NSErrorMsg:(NSError *_Nullable)error;
  40. @end
  41. #endif /* TtsError_h */