com.eg.agent.android.instrumentation.NetworkInformation.ExceptionHelper Maven / Gradle / Ivy
package com.eg.agent.android.instrumentation.NetworkInformation;
import android.util.Log;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.conn.ConnectTimeoutException;
import java.io.EOFException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.ConnectException;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import javax.net.ssl.SSLException;
public class ExceptionHelper
{
public ExceptionHelper()
{
}
public static int exceptionToErrorCode(Exception e)
{
short errorCode = -1;
Log.e("eG Agent", "ExceptionHelper: exception " + e.getClass().getName() + " to error code.");
if(e instanceof ClientProtocolException)
{
errorCode = -1011;
} else if(e instanceof UnknownHostException)
{
errorCode = -1006;
}
else if(e instanceof SocketTimeoutException)
{
errorCode = -1001;
}
else if(e instanceof ConnectTimeoutException)
{
errorCode = -1001;
}
else if(e instanceof ConnectException)
{
errorCode = -1004;
}
else if(e instanceof MalformedURLException)
{
errorCode = -1000;
}
else if(e instanceof SSLException)
{
errorCode = -1200;
}
else if(e instanceof FileNotFoundException)
{
errorCode = -1100;
recordSupportabilityMetric(e, "FileNotFoundException");
}
else if(e instanceof EOFException)
{
recordSupportabilityMetric(e, "EOFException");
}
else if(e instanceof IOException)
{
recordSupportabilityMetric(e, "IOException");
}
else if(e instanceof RuntimeException)
{
recordSupportabilityMetric(e, "RuntimeException");
}
return errorCode;
}
public static void recordSupportabilityMetric(Exception e, String baseExceptionKey) {
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy