-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #892 from benjchristensen/onErrorFlatMap
onErrorFlatMap + OnErrorThrowable
- Loading branch information
Showing
16 changed files
with
430 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
rxjava-core/src/main/java/rx/exceptions/OnErrorThrowable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Copyright 2014 Netflix, Inc. | ||
* | ||
* 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 rx.exceptions; | ||
|
||
public class OnErrorThrowable extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -569558213262703934L; | ||
|
||
private final boolean hasValue; | ||
private final Object value; | ||
|
||
private OnErrorThrowable(Throwable exception) { | ||
super(exception); | ||
hasValue = false; | ||
this.value = null; | ||
} | ||
|
||
private OnErrorThrowable(Throwable exception, Object value) { | ||
super(exception); | ||
hasValue = true; | ||
this.value = value; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
public boolean isValueNull() { | ||
return hasValue; | ||
} | ||
|
||
public static OnErrorThrowable from(Throwable t) { | ||
Throwable cause = Exceptions.getFinalCause(t); | ||
if (cause instanceof OnErrorThrowable.OnNextValue) { | ||
return new OnErrorThrowable(t, ((OnNextValue) cause).getValue()); | ||
} else { | ||
return new OnErrorThrowable(t); | ||
} | ||
} | ||
|
||
/** | ||
* Adds the given value as the final cause of the given Throwable wrapped in OnNextValue RuntimeException.. | ||
* | ||
* @param e | ||
* @param value | ||
* @return Throwable e passed in | ||
*/ | ||
public static Throwable addValueAsLastCause(Throwable e, Object value) { | ||
Exceptions.addCause(e, new OnNextValue(value)); | ||
return e; | ||
} | ||
|
||
public static class OnNextValue extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -3454462756050397899L; | ||
private final Object value; | ||
|
||
public OnNextValue(Object value) { | ||
super("OnError while emitting onNext value: " + value); | ||
this.value = value; | ||
} | ||
|
||
public Object getValue() { | ||
return value; | ||
} | ||
|
||
} | ||
} |
119 changes: 0 additions & 119 deletions
119
rxjava-core/src/main/java/rx/operators/OperationOnErrorResumeNextViaFunction.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.