File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
src/main/java/com/blockscore/models/error Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .annotation .JsonProperty ;
44import org .jetbrains .annotations .NotNull ;
5+ import org .jetbrains .annotations .Nullable ;
6+ import retrofit .RetrofitError ;
57
68/**
79 * Blockscore Error model.
@@ -12,6 +14,21 @@ public class BlockscoreError {
1214 @ JsonProperty ("error" )
1315 private RequestError mRequestError ;
1416
17+ /**
18+ * Converts a Retrofit Error into a Blockscore Error.
19+ * @param cause Retrofit error to convert.
20+ * @return Blockscore Error
21+ */
22+ @ Nullable
23+ public static BlockscoreError getBlockscoreError (@ NotNull final RetrofitError cause ) {
24+ Object rawError = cause .getBodyAs (BlockscoreError .class );
25+ if (rawError instanceof BlockscoreError ) {
26+ return (BlockscoreError ) rawError ;
27+ } else {
28+ return null ;
29+ }
30+ }
31+
1532 /**
1633 * Returns the error details.
1734 * @return Error details.
You can’t perform that action at this time.
0 commit comments