Skip to content

Commit

Permalink
perf: improve Ali error message
Browse files Browse the repository at this point in the history
  • Loading branch information
tisfeng committed Dec 21, 2023
1 parent 531d826 commit 6c7694e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Easydict/Feature/Service/Ali/AliResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ import Foundation
"detectLanguage": "en"
}
}

error:
{
"requestId": "877D2097-6FE4-4B24-BAF1-41AB561C1E67",
"success": false,
"httpStatusCode": 500,
"code": "ParamError",
"message": "Query length limit exceeded",
"data": null
}
*/

struct AliResponse: Codable {
Expand Down
3 changes: 1 addition & 2 deletions Easydict/Feature/Service/Ali/AliService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class AliService: QueryService {
result.translatedResults = [translateText.unescapedXML()]
completion(result, nil)
} else {
let ezError = EZError(type: value.httpStatusCode == 500 ? .unsupportedLanguage : .noResultsFound)
ezError.errorDataMessage = value.message ?? "ali translate failed"
let ezError = EZError(type: .API, description: value.code, errorDataMessage: value.message)
completion(result, ezError)
}
case let .failure(error):
Expand Down

0 comments on commit 6c7694e

Please sign in to comment.