Skip to content

Commit

Permalink
Merge pull request #55 from Fastholf/add-crash-description
Browse files Browse the repository at this point in the history
Pass ClassCastException to WrongViewFinderException
  • Loading branch information
vivchar authored Apr 8, 2021
2 parents dbea627 + b66ade5 commit a8d8711
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected void bindInner(@NonNull final M model, @NonNull final VH holder, @NonN
/* temporary workaround to catch ViewFinder ClassCastException,
by some reason ViewHolder.getViewFinder() catch doesn't work */
if (e.getMessage().contains(ViewFinder.class.getSimpleName())) {
throw new WrongViewFinderException();
throw new WrongViewFinderException(e);
} else {
throw e;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public VF getViewFinder() {
try {
mViewFinder = (VF) ViewFinderFactory.create(itemView);
} catch (ClassCastException e) { //TODO vivchar: by some reason it does not catch
throw new WrongViewFinderException();
throw new WrongViewFinderException(e);
}
}
return mViewFinder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.github.vivchar.rendererrecyclerviewadapter;

import androidx.annotation.NonNull;

/**
* Created by Vivchar Vitaly on 11.07.19.
*/

public class WrongViewFinderException extends RuntimeException {

public WrongViewFinderException() {
public WrongViewFinderException(@NonNull final ClassCastException e) {
super("Looks like you are trying to use a custom ViewFinder, " +
"but forgot to implement or register it, " +
"please use RendererRecyclerViewAdapter.registerViewFinder() to support your custom ViewFinder.");
"but forgot to implement or register it. As a result you've got the following error:" +
" \"" + e.getMessage() + "\". " +
"Please use RendererRecyclerViewAdapter.registerViewFinder() to support your custom ViewFinder.");
}
}

0 comments on commit a8d8711

Please sign in to comment.