-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(retrofit): move url attribute from SpinnakerHttpException to SpinnakerServerException #1110
Changes from all commits
7c9b572
b212235
660c79b
2fdbee3
8eac81a
669d649
f4bb645
64f7673
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -59,11 +59,11 @@ public Throwable handleError(RetrofitError e) { | |||||
} | ||||||
return retval; | ||||||
case NETWORK: | ||||||
return new SpinnakerNetworkException(e.getMessage(), e.getCause()); | ||||||
return new SpinnakerNetworkException(e); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This becomes easy to change too
Suggested change
|
||||||
case CONVERSION: | ||||||
return new SpinnakerConversionException(e.getMessage(), e.getCause()); | ||||||
return new SpinnakerConversionException(e); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
default: | ||||||
return new SpinnakerServerException(e.getMessage(), e.getCause()); | ||||||
return new SpinnakerServerException(e); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,20 +18,57 @@ | |
|
||
import com.netflix.spinnaker.kork.annotations.NonnullByDefault; | ||
import com.netflix.spinnaker.kork.exceptions.SpinnakerException; | ||
import lombok.Getter; | ||
import okhttp3.Request; | ||
dbyron-sf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import retrofit.RetrofitError; | ||
|
||
/** Represents an error while attempting to execute a retrofit http client request. */ | ||
@NonnullByDefault | ||
public class SpinnakerServerException extends SpinnakerException { | ||
|
||
public SpinnakerServerException(String message, Throwable cause) { | ||
super(message, cause); | ||
@Getter private final String url; | ||
|
||
/** Construct a SpinnakerServerException corresponding to a RetrofitError. */ | ||
public SpinnakerServerException(RetrofitError e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then these go away and allows for only the |
||
super(e.getMessage(), e.getCause()); | ||
url = e.getUrl(); | ||
} | ||
|
||
public SpinnakerServerException(Throwable cause) { | ||
/** | ||
* Construct a SpinnakerServerException from retrofit2 with no cause (e.g. a non-200 http | ||
* response). | ||
*/ | ||
public SpinnakerServerException(Request request) { | ||
super(); | ||
url = request.url().toString(); | ||
} | ||
|
||
/** | ||
* Construct a SpinnakerServerException from retrofit2 with a cause (e.g. an exception sending a | ||
* request or processing a response). | ||
*/ | ||
public SpinnakerServerException(Throwable cause, Request request) { | ||
super(cause); | ||
this.url = request.url().toString(); | ||
} | ||
|
||
public SpinnakerServerException() {} | ||
/** | ||
* Construct a SpinnakerServerException from retrofit2 with a message and cause (e.g. an exception | ||
* converting a response to the specified type). | ||
*/ | ||
public SpinnakerServerException(String message, Throwable cause, Request request) { | ||
super(message, cause); | ||
this.url = request.url().toString(); | ||
} | ||
|
||
/** | ||
* Construct a SpinnakerServerException from another SpinnakerServerException (e.g. via | ||
* newInstance). | ||
*/ | ||
public SpinnakerServerException(String message, SpinnakerServerException cause) { | ||
super(message, cause); | ||
this.url = cause.getUrl(); | ||
} | ||
|
||
@Override | ||
public SpinnakerServerException newInstance(String message) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof, that sucks we need to add the false everywhere. May be nice to have a
implements NonRetryableException
or something like that, but that is separate from this PR