Skip to content

Commit

Permalink
No track to Share : Define and throw a dedicated exception instead of…
Browse files Browse the repository at this point in the history
… using a generic one.
  • Loading branch information
jasmanpreet0209 committed Oct 9, 2023
1 parent 097faa9 commit 0f44303
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/de/dennisguse/opentracks/share/ShareUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.io.file.TrackFileFormat;
import de.dennisguse.opentracks.settings.PreferencesUtils;

class NoTracksToShareException extends RuntimeException{
public NoTracksToShareException()
{
super("Did not find any tracks to share.");
}
public NoTracksToShareException(String message)
{
super(message);
}
}
public class ShareUtils {

private static final String TAG = ShareUtils.class.getSimpleName();
Expand All @@ -34,7 +43,7 @@ private ShareUtils() {
*/
public static Intent newShareFileIntent(Context context, Track.Id... trackIds) {
if (trackIds.length == 0) {
throw new RuntimeException("Need to share at least one track.");
throw new NoTracksToShareException("Need to share at least one track.");
}

ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
Expand Down

0 comments on commit 0f44303

Please sign in to comment.