33 lines
1.2 KiB
Java
33 lines
1.2 KiB
Java
// Copyright (c) 2021, Fr.Terrot. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package io.gitea.mylyn.core.exceptions;
|
|
|
|
import java.io.FileNotFoundException;
|
|
import java.io.IOException;
|
|
import java.net.ConnectException;
|
|
import java.net.NoRouteToHostException;
|
|
|
|
import javax.net.ssl.SSLHandshakeException;
|
|
|
|
public class GiteaExceptionHandler {
|
|
|
|
public static GiteaException handle(Throwable e) {
|
|
if (e instanceof SSLHandshakeException) {
|
|
return new GiteaException("Invalid TLS Certificate: " + e.getMessage());
|
|
} else if (e instanceof ConnectException) {
|
|
return new GiteaException("Connection refused");
|
|
} else if (e instanceof NoRouteToHostException) {
|
|
return new GiteaException("No route to host");
|
|
} else if (e instanceof FileNotFoundException) {
|
|
return new GiteaException("Invalid path in host");
|
|
} else if (e instanceof IOException) {
|
|
return new GiteaException("Invalid username/password/private token combination");
|
|
}
|
|
|
|
return new GiteaException("Unknown Exception: " + e.getMessage());
|
|
}
|
|
|
|
}
|