cep21 / circuit

An efficient and feature complete Hystrix like Go implementation of the circuit breaker pattern.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom errors

sharadbhat opened this issue · comments

Hi, can we pass custom errors as failures of the circuit?

From what I understood, we can return error from the Execute method. But it isn't considered as a failure of the circuit. I wanted to find out if it was possible to do so.

Thanks in advance!

I figured it out.

For anyone wondering, an error returned by the inner function in Execute is considered an error of the circuit unless SimpleBadRequest is used.

Correct me if I'm wrong.

That is correct. I try to clarify it a bit on the godoc of Execute

// Execute the circuit.  Prefer this over Go.  Similar to http://netflix.github.io/Hystrix/javadoc/com/netflix/hystrix/HystrixCommand.html#execute--
// The returned error will either be the result of runFunc, the result of fallbackFunc, or an internal library error.
// Internal library errors will match the interface Error and you can use type casting to check this.