This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
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 #572 from vegaprotocol/release/v0.15.1
Release/v0.15.1
- Loading branch information
Showing
17 changed files
with
376 additions
and
208 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//go:build !windows | ||
// +build !windows | ||
|
||
package cmd | ||
|
||
func toZapLogPath(p string) string { | ||
return p | ||
} |
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,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"os" | ||
|
||
"go.uber.org/zap" | ||
) | ||
|
||
func init() { | ||
err := zap.RegisterSink("winfile", newWinFileSink) | ||
if err != nil { | ||
panic(fmt.Errorf("couldn't register the windows file sink: %w", err)) | ||
} | ||
} | ||
|
||
func toZapLogPath(logPath string) string { | ||
return "winfile:///" + logPath | ||
} | ||
|
||
// newWinFileSink creates a log sink on Windows machines as zap, by default, | ||
// doesn't support Windows paths. A workaround is to create a fake winfile | ||
// scheme and register it with zap instead. This workaround is taken from | ||
// the GitHub issue at https://github.com/uber-go/zap/issues/621. | ||
func newWinFileSink(u *url.URL) (zap.Sink, error) { | ||
// Remove leading slash left by url.Parse(). | ||
return os.OpenFile(u.Path[1:], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0o644) // nolint:gomnd | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,45 @@ | ||
package node | ||
|
||
import "errors" | ||
import ( | ||
"errors" | ||
"fmt" | ||
"strings" | ||
|
||
typespb "code.vegaprotocol.io/protos/vega" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
) | ||
|
||
var ErrNoHostSpecified = errors.New("no host specified") | ||
|
||
type ErrorCode codes.Code | ||
|
||
type StatusError struct { | ||
Code codes.Code | ||
Details []string | ||
} | ||
|
||
func (e *StatusError) Error() string { | ||
return fmt.Sprintf("%s - %v", e.Code.String(), strings.Join(e.Details, ", ")) | ||
} | ||
|
||
// intoStatusError extract useful information from a gRPC status error. | ||
// Returns nil if the underlying error is not a gRPC status error. | ||
func intoStatusError(err error) *StatusError { | ||
st, ok := status.FromError(err) | ||
if !ok { | ||
return nil | ||
} | ||
statusErr := &StatusError{ | ||
Code: st.Code(), | ||
Details: []string{}, | ||
} | ||
for _, v := range st.Details() { | ||
v, ok := v.(*typespb.ErrorDetail) | ||
if !ok { | ||
continue | ||
} | ||
statusErr.Details = append(statusErr.Details, v.GetMessage()) | ||
} | ||
return statusErr | ||
} |
Oops, something went wrong.