diff --git a/include/dfm-io/dfm-io/error/en.h b/include/dfm-io/dfm-io/error/en.h index a140a45..bc4c5b8 100644 --- a/include/dfm-io/dfm-io/error/en.h +++ b/include/dfm-io/dfm-io/error/en.h @@ -66,6 +66,7 @@ enum DFMIOErrorCode { DFM_IO_ERROR_OPEN_FLAG_ERROR, // File open flag is error DFM_IO_ERROR_INFO_NO_ATTRIBUTE, // File info has no attribute DFM_IO_ERROR_FTS_OPEN, // open file by fts failed + DFM_IO_ERROR_HOST_IS_DOWN, // remote server maybe down }; inline const QString GetError_En(DFMIOErrorCode errorCode) @@ -179,6 +180,8 @@ inline const QString GetError_En(DFMIOErrorCode errorCode) return QObject::tr("open file by fts failed"); case DFM_IO_ERROR_USER_FAILED: return QString(); + case DFM_IO_ERROR_HOST_IS_DOWN: + return QObject::tr("Host is down"); } return QString("Unknown error"); diff --git a/src/dfm-io/dfm-io/dfileinfo.cpp b/src/dfm-io/dfm-io/dfileinfo.cpp index 66a8bc5..f169efa 100644 --- a/src/dfm-io/dfm-io/dfileinfo.cpp +++ b/src/dfm-io/dfm-io/dfileinfo.cpp @@ -216,6 +216,14 @@ void DFileInfoPrivate::setErrorFromGError(GError *gerror) { if (!gerror) return; + + if (g_error_matches(gerror, G_IO_ERROR,G_IO_ERROR_FAILED) && + QString(gerror->message).contains(strerror(EHOSTDOWN))) { + error.setCode(DFMIOErrorCode::DFM_IO_ERROR_HOST_IS_DOWN); + error.setMessage(gerror->message); + return; + } + error.setCode(DFMIOErrorCode(gerror->code)); if (error.code() == DFMIOErrorCode::DFM_IO_ERROR_FAILED) error.setMessage(gerror->message);