Skip to content

Commit

Permalink
Better displaying of unknown errors
Browse files Browse the repository at this point in the history
So the stacktrace can be analysed on Play Store
  • Loading branch information
fkeglevich committed Jan 19, 2019
1 parent 7936278 commit 0e250e9
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.fkeglevich.rawdumper.raw.info.DeviceInfo;
import com.fkeglevich.rawdumper.raw.info.DeviceInfoLoader;
import com.fkeglevich.rawdumper.util.exception.MessageException;
import com.fkeglevich.rawdumper.util.exception.UnknownMessageException;

/**
* Created by Flávio Keglevich on 03/09/2017.
Expand All @@ -41,7 +42,7 @@ protected DeviceInfo call(Void argument) throws MessageException
{
re.printStackTrace();
Log.e("LoadDeviceInfoFunction", "RuntimeException: " + re.getMessage());
throw re;
throw new UnknownMessageException(re);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@

public abstract class MessageException extends Exception
{
public MessageException()
{
super();
}

public MessageException(Throwable cause)
{
super(cause);
}

public abstract String getMessageResource(Context context);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2019, Flávio Keglevich
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.fkeglevich.rawdumper.util.exception;

import android.content.Context;

import com.fkeglevich.rawdumper.R;

public class UnknownMessageException extends MessageException
{
public UnknownMessageException(Throwable cause)
{
super(cause);
}

@Override
public String getMessageResource(Context context)
{
return context.getResources().getString(R.string.unknown_error, getCause().getMessage());
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<string name="about_title">Sobre</string>
<string name="app_name_with_version">Raw Dumper v<xliff:g id="app_version">%s</xliff:g></string>
<string name="error_opening_camera">A câmera não pode ser iniciada. Reinicie seu dispositivo e tente novamente.</string>
<string name="unknown_error">Um erro inesperado aconteceu: <xliff:g id="error">%s</xliff:g></string>
<string name="permission_error">Este aplicativo necessita de todas as permissões para funcionar.</string>
<string name="root_access_error">Este aplicativo somente funciona em dispositivos com root.</string>
<string name="terminating_dialog_button">Sair</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
\nDevice model: <xliff:g id="model_name">%s</xliff:g>
</string>

<string name="unknown_error">An unexpected error occurred: <xliff:g id="error">%s</xliff:g></string>
<string name="permission_error">This app needs all requested permissions.</string>
<string name="root_access_error">This app only works with root access.</string>

Expand Down

0 comments on commit 0e250e9

Please sign in to comment.