-
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 5 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); | ||||||
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,23 +18,46 @@ | |
|
||
import com.netflix.spinnaker.kork.annotations.NonnullByDefault; | ||
import com.netflix.spinnaker.kork.exceptions.SpinnakerException; | ||
import retrofit.RetrofitError; | ||
import retrofit2.Response; | ||
|
||
/** 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); | ||
private final String url; | ||
dbyron-sf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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(Response retrofit2Response) { | ||
super(); | ||
url = retrofit2Response.raw().request().url().toString(); | ||
} | ||
|
||
public SpinnakerServerException(Throwable cause) { | ||
public SpinnakerServerException(Throwable cause, String url) { | ||
super(cause); | ||
this.url = url; | ||
} | ||
|
||
public SpinnakerServerException() {} | ||
public SpinnakerServerException(String message, Throwable cause, String url) { | ||
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. I think with this new method signature, we can probably get rid of all the retrofit constructors tbh. This will at least clean up the other exceptions and only require updating the one constructor in each other exception. This also keeps the |
||
super(message, cause); | ||
this.url = url; | ||
} | ||
|
||
public SpinnakerServerException(String message, SpinnakerServerException cause) { | ||
super(message, cause); | ||
this.url = cause.getUrl(); | ||
} | ||
|
||
@Override | ||
public SpinnakerServerException newInstance(String message) { | ||
return new SpinnakerServerException(message, this); | ||
} | ||
|
||
dbyron-sf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public String getUrl() { | ||
dbyron-sf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return this.url; | ||
dbyron-sf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
dbyron-sf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
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.
This becomes easy to change too