Skip to content

Commit

Permalink
RESPONSE ERROR - CENTRALIZED
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
  • Loading branch information
marinofaggiana committed Oct 21, 2024
1 parent dc721df commit b6f6c0c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions iOSClient/NCGlobal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ class NCGlobal: NSObject {
let errorPreconditionFailed: Int = 412
let errorUnsupportedMediaType: Int = 415
let errorInternalServerError: Int = 500
let errorMaintenance: Int = 503
let errorQuota: Int = 507
let errorUnauthorized997: Int = 997
let errorExplicitlyCancelled: Int = -999
Expand Down
15 changes: 14 additions & 1 deletion iOSClient/Networking/NCNetworking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,20 @@ class NCNetworking: NSObject, NextcloudKitDelegate {
#endif
}

func request<Value>(_ request: Alamofire.DataRequest, didParseResponse response: Alamofire.AFDataResponse<Value>) { }
func request<Value>(_ request: Alamofire.DataRequest, didParseResponse response: Alamofire.AFDataResponse<Value>) {
/// RESPONSE ERROR
if let statusCode = response.response?.statusCode {
switch statusCode {
case NCGlobal.shared.errorMaintenance:
if let errorDescription = NKError.getErrorDescription(for: statusCode) {
let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: errorDescription)
NCContentPresenter().showWarning(error: error, priority: .max)
}
default:
break
}
}
}

// MARK: -

Expand Down
2 changes: 0 additions & 2 deletions iOSClient/Networking/NCService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ class NCService: NSObject {
switch await NCNetworking.shared.getServerStatus(serverUrl: serverUrl, options: NKRequestOptions(queue: NextcloudKit.shared.nkCommonInstance.backgroundQueue)) {
case .success(let serverInfo):
if serverInfo.maintenance {
let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_maintenance_mode_")
NCContentPresenter().showWarning(error: error, priority: .max)
return false
} else if serverInfo.productName.lowercased().contains("owncloud") {
let error = NKError(errorCode: NCGlobal.shared.errorInternalError, errorDescription: "_warning_owncloud_")
Expand Down
2 changes: 1 addition & 1 deletion iOSClient/Supporting Files/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@
"_user_" = "User";
"_add_subtitle_" = "Add an external subtitle";
"_add_audio_" = "Add an external audio";
"_maintenance_mode_" = "Server is currently in maintenance mode";
"_server_maintenance_mode_" = "Server is currently in maintenance mode";
"_upload_foreground_msg_" = "Do not close %@ to complete the transfer …";
"_upload_background_msg_" = "Files upload in progress …";
"_create_folder_error_" = "An error has occurred while creating the folder:\n%@.\n\nPlease resolve the issue as soon as possible.\n\nAll uploads are suspended until the problem is resolved.\n";
Expand Down

0 comments on commit b6f6c0c

Please sign in to comment.