From adcdff045940349e30fb3eccb4dd6c07d2e22654 Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Mon, 18 Nov 2024 15:10:10 +0100 Subject: [PATCH 1/3] Remove support for legacy errors -legacyErrors=true has been supported for 18+ months, let's drop it --- README.md | 1 - errors.go.tmpl | 5 --- errors.legacy.go.tmpl | 90 ------------------------------------------- main.go.tmpl | 5 --- 4 files changed, 101 deletions(-) delete mode 100644 errors.legacy.go.tmpl diff --git a/README.md b/README.md index 2f612c0..cc61458 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ Change any of the following values by passing `-option="Value"` CLI flag to `web | `-json=jsoniter` | `"stdlib"` | use alternative json encoding package | v0.12.0 | | `-fixEmptyArrays` | `false` | force empty array `[]` instead of `null` in JSON (see Go [#27589][go27589]) | v0.13.0 | | `-errorStackTrace` | `false` | enables error stack traces | v0.14.0 | -| `-legacyErrors` | `false` | enable legacy errors (v0.10.0 or older) | v0.11.0 | | `-webrpcHeader` | `true` | enable client send webrpc version in http headers | v0.16.0 | Example: diff --git a/errors.go.tmpl b/errors.go.tmpl index 7df32fd..e409369 100644 --- a/errors.go.tmpl +++ b/errors.go.tmpl @@ -36,11 +36,6 @@ func (e WebRPCError) Is(target error) bool { if rpcErr, ok := target.(WebRPCError); ok { return rpcErr.Code == e.Code } -{{- if $opts.legacyErrors }} - if legacyErr, ok := target.(legacyError); ok { - return legacyErr.Code == e.Code - } -{{- end }} return errors.Is(e.cause, target) } diff --git a/errors.legacy.go.tmpl b/errors.legacy.go.tmpl deleted file mode 100644 index 49ca29f..0000000 --- a/errors.legacy.go.tmpl +++ /dev/null @@ -1,90 +0,0 @@ -{{define "legacyErrors"}} -// -// Legacy errors -// - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func Errorf(err legacyError, format string, args ...interface{}) WebRPCError { - return err.WebRPCError.WithCausef(format, args...) -} - -// Deprecated: Use .WithCause() method on WebRPCError. -func WrapError(err legacyError, cause error, format string, args ...interface{}) WebRPCError { - return err.WebRPCError.WithCausef("%v: %w", fmt.Errorf(format, args...), cause) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func Failf(format string, args ...interface{}) WebRPCError { - return Errorf(ErrFail, format, args...) -} - -// Deprecated: Use .WithCause() method on WebRPCError. -func WrapFailf(cause error, format string, args ...interface{}) WebRPCError { - return WrapError(ErrFail, cause, format, args...) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorNotFound(format string, args ...interface{}) WebRPCError { - return Errorf(ErrNotFound, format, args...) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorInvalidArgument(argument string, validationMsg string) WebRPCError { - return Errorf(ErrInvalidArgument, argument+" "+validationMsg) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorRequiredArgument(argument string) WebRPCError { - return ErrorInvalidArgument(argument, "is required") -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorInternal(format string, args ...interface{}) WebRPCError { - return Errorf(ErrInternal, format, args...) -} - -type legacyError struct { WebRPCError } - -// Legacy errors (webrpc v0.10.0 and earlier). Will be removed. -var ( - // Deprecated. Define errors in RIDL schema. - ErrCanceled = legacyError{WebRPCError{Code: -10000, Name: "ErrCanceled", Message: "canceled", HTTPStatus: 408 /* RequestTimeout */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnknown = legacyError{WebRPCError{Code: -10001, Name: "ErrUnknown", Message: "unknown", HTTPStatus: 400 /* Bad Request */ }} - // Deprecated. Define errors in RIDL schema. - ErrFail = legacyError{WebRPCError{Code: -10002, Name: "ErrFail", Message: "fail", HTTPStatus: 422 /* Unprocessable Entity */ }} - // Deprecated. Define errors in RIDL schema. - ErrInvalidArgument = legacyError{WebRPCError{Code: -10003, Name: "ErrInvalidArgument", Message: "invalid argument", HTTPStatus: 400 /* BadRequest */ }} - // Deprecated. Define errors in RIDL schema. - ErrDeadlineExceeded = legacyError{WebRPCError{Code: -10004, Name: "ErrDeadlineExceeded", Message: "deadline exceeded", HTTPStatus: 408 /* RequestTimeout */ }} - // Deprecated. Define errors in RIDL schema. - ErrNotFound = legacyError{WebRPCError{Code: -10005, Name: "ErrNotFound", Message: "not found", HTTPStatus: 404 /* Not Found */ }} - // Deprecated. Define errors in RIDL schema. - ErrBadRoute = legacyError{WebRPCError{Code: -10006, Name: "ErrBadRoute", Message: "bad route", HTTPStatus: 404 /* Not Found */ }} - // Deprecated. Define errors in RIDL schema. - ErrAlreadyExists = legacyError{WebRPCError{Code: -10007, Name: "ErrAlreadyExists", Message: "already exists", HTTPStatus: 409 /* Conflict */ }} - // Deprecated. Define errors in RIDL schema. - ErrPermissionDenied = legacyError{WebRPCError{Code: -10008, Name: "ErrPermissionDenied", Message: "permission denied", HTTPStatus: 403 /* Forbidden */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnauthenticated = legacyError{WebRPCError{Code: -10009, Name: "ErrUnauthenticated", Message: "unauthenticated", HTTPStatus: 401 /* Unauthorized */ }} - // Deprecated. Define errors in RIDL schema. - ErrResourceExhausted = legacyError{WebRPCError{Code: -10010, Name: "ErrResourceExhausted", Message: "resource exhausted", HTTPStatus: 403 /* Forbidden */ }} - // Deprecated. Define errors in RIDL schema. - ErrFailedPrecondition = legacyError{WebRPCError{Code: -10011, Name: "ErrFailedPrecondition", Message: "failed precondition", HTTPStatus: 412 /* Precondition Failed */ }} - // Deprecated. Define errors in RIDL schema. - ErrAborted = legacyError{WebRPCError{Code: -10012, Name: "ErrAborted", Message: "aborted", HTTPStatus: 409 /* Conflict */ }} - // Deprecated. Define errors in RIDL schema. - ErrOutOfRange = legacyError{WebRPCError{Code: -10013, Name: "ErrOutOfRange", Message: "out of range", HTTPStatus: 400 /* Bad Request */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnimplemented = legacyError{WebRPCError{Code: -10014, Name: "ErrUnimplemented", Message: "unimplemented", HTTPStatus: 501 /* Not Implemented */ }} - // Deprecated. Define errors in RIDL schema. - ErrInternal = legacyError{WebRPCError{Code: -10015, Name: "ErrInternal", Message: "internal", HTTPStatus: 500 /* Internal Server Error */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnavailable = legacyError{WebRPCError{Code: -10016, Name: "ErrUnavailable", Message: "unavailable", HTTPStatus: 503 /* Service Unavailable */ }} - // Deprecated. Define errors in RIDL schema. - ErrDataLoss = legacyError{WebRPCError{Code: -10017, Name: "ErrDataLoss", Message: "data loss", HTTPStatus: 500 /* Internal Server Error */ }} - // Deprecated. Define errors in RIDL schema. - ErrNone = legacyError{WebRPCError{Code: -10018, Name: "ErrNone", Message: "", HTTPStatus: 200 /* OK */ }} -) - -{{- end }} diff --git a/main.go.tmpl b/main.go.tmpl index 4685ec5..2cc50a7 100644 --- a/main.go.tmpl +++ b/main.go.tmpl @@ -10,7 +10,6 @@ {{- set $opts "importTypesFrom" (default .Opts.importTypesFrom "" ) -}} {{- set $opts "fixEmptyArrays" (ternary (in .Opts.fixEmptyArrays "" "true") true false) -}} {{- set $opts "errorStackTrace" (ternary (in .Opts.errorStackTrace "" "true") true false) -}} -{{- set $opts "legacyErrors" (ternary (in .Opts.legacyErrors "" "true") true false) -}} {{- set $opts "webrpcHeader" (ternary (eq (default .Opts.webrpcHeader "true") "false") false true) -}} {{- $typePrefix := (last (split "/" $opts.importTypesFrom)) -}} @@ -170,8 +169,4 @@ func parseWebrpcGenVersions(header string) (*WebrpcGenVersions, error) { {{ template "errors" dict "WebrpcErrors" .WebrpcErrors "SchemaErrors" .Errors "Opts" $opts "TypePrefix" $typePrefix }} -{{- if $opts.legacyErrors }} -{{ template "legacyErrors" . }} -{{- end }} - {{- end }} From 25e33a96300d9501466c6c8b724ff26adb20bcfc Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Mon, 18 Nov 2024 15:25:09 +0100 Subject: [PATCH 2/3] Update golang-basic example --- _examples/golang-basics/example.gen.go | 93 +------------------------ _examples/golang-basics/example_test.go | 12 ---- _examples/golang-basics/main.go | 15 +--- 3 files changed, 4 insertions(+), 116 deletions(-) diff --git a/_examples/golang-basics/example.gen.go b/_examples/golang-basics/example.gen.go index 2522bd1..9d979f9 100644 --- a/_examples/golang-basics/example.gen.go +++ b/_examples/golang-basics/example.gen.go @@ -2,7 +2,7 @@ // -- // Code generated by webrpc-gen@v0.21.0 with ../../../gen-golang generator. DO NOT EDIT. // -// webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -legacyErrors -fixEmptyArrays -out=./example.gen.go +// webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -fixEmptyArrays -out=./example.gen.go package main import ( @@ -1005,9 +1005,6 @@ func (e WebRPCError) Is(target error) bool { if rpcErr, ok := target.(WebRPCError); ok { return rpcErr.Code == e.Code } - if legacyErr, ok := target.(legacyError); ok { - return legacyErr.Code == e.Code - } return errors.Is(e.cause, target) } @@ -1058,91 +1055,3 @@ var ( ErrUnauthorized = WebRPCError{Code: 400200, Name: "Unauthorized", Message: "unauthorized", HTTPStatus: 401} ErrUserNotFound = WebRPCError{Code: 400300, Name: "UserNotFound", Message: "user not found", HTTPStatus: 400} ) - -// -// Legacy errors -// - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func Errorf(err legacyError, format string, args ...interface{}) WebRPCError { - return err.WebRPCError.WithCausef(format, args...) -} - -// Deprecated: Use .WithCause() method on WebRPCError. -func WrapError(err legacyError, cause error, format string, args ...interface{}) WebRPCError { - return err.WebRPCError.WithCausef("%v: %w", fmt.Errorf(format, args...), cause) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func Failf(format string, args ...interface{}) WebRPCError { - return Errorf(ErrFail, format, args...) -} - -// Deprecated: Use .WithCause() method on WebRPCError. -func WrapFailf(cause error, format string, args ...interface{}) WebRPCError { - return WrapError(ErrFail, cause, format, args...) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorNotFound(format string, args ...interface{}) WebRPCError { - return Errorf(ErrNotFound, format, args...) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorInvalidArgument(argument string, validationMsg string) WebRPCError { - return Errorf(ErrInvalidArgument, argument+" "+validationMsg) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorRequiredArgument(argument string) WebRPCError { - return ErrorInvalidArgument(argument, "is required") -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorInternal(format string, args ...interface{}) WebRPCError { - return Errorf(ErrInternal, format, args...) -} - -type legacyError struct{ WebRPCError } - -// Legacy errors (webrpc v0.10.0 and earlier). Will be removed. -var ( - // Deprecated. Define errors in RIDL schema. - ErrCanceled = legacyError{WebRPCError{Code: -10000, Name: "ErrCanceled", Message: "canceled", HTTPStatus: 408 /* RequestTimeout */}} - // Deprecated. Define errors in RIDL schema. - ErrUnknown = legacyError{WebRPCError{Code: -10001, Name: "ErrUnknown", Message: "unknown", HTTPStatus: 400 /* Bad Request */}} - // Deprecated. Define errors in RIDL schema. - ErrFail = legacyError{WebRPCError{Code: -10002, Name: "ErrFail", Message: "fail", HTTPStatus: 422 /* Unprocessable Entity */}} - // Deprecated. Define errors in RIDL schema. - ErrInvalidArgument = legacyError{WebRPCError{Code: -10003, Name: "ErrInvalidArgument", Message: "invalid argument", HTTPStatus: 400 /* BadRequest */}} - // Deprecated. Define errors in RIDL schema. - ErrDeadlineExceeded = legacyError{WebRPCError{Code: -10004, Name: "ErrDeadlineExceeded", Message: "deadline exceeded", HTTPStatus: 408 /* RequestTimeout */}} - // Deprecated. Define errors in RIDL schema. - ErrNotFound = legacyError{WebRPCError{Code: -10005, Name: "ErrNotFound", Message: "not found", HTTPStatus: 404 /* Not Found */}} - // Deprecated. Define errors in RIDL schema. - ErrBadRoute = legacyError{WebRPCError{Code: -10006, Name: "ErrBadRoute", Message: "bad route", HTTPStatus: 404 /* Not Found */}} - // Deprecated. Define errors in RIDL schema. - ErrAlreadyExists = legacyError{WebRPCError{Code: -10007, Name: "ErrAlreadyExists", Message: "already exists", HTTPStatus: 409 /* Conflict */}} - // Deprecated. Define errors in RIDL schema. - ErrPermissionDenied = legacyError{WebRPCError{Code: -10008, Name: "ErrPermissionDenied", Message: "permission denied", HTTPStatus: 403 /* Forbidden */}} - // Deprecated. Define errors in RIDL schema. - ErrUnauthenticated = legacyError{WebRPCError{Code: -10009, Name: "ErrUnauthenticated", Message: "unauthenticated", HTTPStatus: 401 /* Unauthorized */}} - // Deprecated. Define errors in RIDL schema. - ErrResourceExhausted = legacyError{WebRPCError{Code: -10010, Name: "ErrResourceExhausted", Message: "resource exhausted", HTTPStatus: 403 /* Forbidden */}} - // Deprecated. Define errors in RIDL schema. - ErrFailedPrecondition = legacyError{WebRPCError{Code: -10011, Name: "ErrFailedPrecondition", Message: "failed precondition", HTTPStatus: 412 /* Precondition Failed */}} - // Deprecated. Define errors in RIDL schema. - ErrAborted = legacyError{WebRPCError{Code: -10012, Name: "ErrAborted", Message: "aborted", HTTPStatus: 409 /* Conflict */}} - // Deprecated. Define errors in RIDL schema. - ErrOutOfRange = legacyError{WebRPCError{Code: -10013, Name: "ErrOutOfRange", Message: "out of range", HTTPStatus: 400 /* Bad Request */}} - // Deprecated. Define errors in RIDL schema. - ErrUnimplemented = legacyError{WebRPCError{Code: -10014, Name: "ErrUnimplemented", Message: "unimplemented", HTTPStatus: 501 /* Not Implemented */}} - // Deprecated. Define errors in RIDL schema. - ErrInternal = legacyError{WebRPCError{Code: -10015, Name: "ErrInternal", Message: "internal", HTTPStatus: 500 /* Internal Server Error */}} - // Deprecated. Define errors in RIDL schema. - ErrUnavailable = legacyError{WebRPCError{Code: -10016, Name: "ErrUnavailable", Message: "unavailable", HTTPStatus: 503 /* Service Unavailable */}} - // Deprecated. Define errors in RIDL schema. - ErrDataLoss = legacyError{WebRPCError{Code: -10017, Name: "ErrDataLoss", Message: "data loss", HTTPStatus: 500 /* Internal Server Error */}} - // Deprecated. Define errors in RIDL schema. - ErrNone = legacyError{WebRPCError{Code: -10018, Name: "ErrNone", Message: "", HTTPStatus: 200 /* OK */}} -) diff --git a/_examples/golang-basics/example_test.go b/_examples/golang-basics/example_test.go index 7b3117c..ff8078d 100644 --- a/_examples/golang-basics/example_test.go +++ b/_examples/golang-basics/example_test.go @@ -93,15 +93,3 @@ func TestGetUser(t *testing.T) { assert.NoError(t, err) } } - -func TestLegacyErrors(t *testing.T) { - { - _, err := client.GetUser(context.Background(), nil, 0) - assert.Error(t, err) - assert.ErrorIs(t, err, ErrInvalidArgument) - - _, err = client.GetUser(context.Background(), nil, 1000) - assert.Error(t, err) - assert.ErrorIs(t, err, ErrUnavailable) - } -} diff --git a/_examples/golang-basics/main.go b/_examples/golang-basics/main.go index 8bf1243..ef030f8 100644 --- a/_examples/golang-basics/main.go +++ b/_examples/golang-basics/main.go @@ -1,11 +1,10 @@ package main -//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -legacyErrors -fixEmptyArrays -out=./example.gen.go +//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=example.ridl -target=../../../gen-golang -pkg=main -server -client -fixEmptyArrays -out=./example.gen.go import ( "context" "fmt" - "io" "log" "net/http" @@ -82,7 +81,7 @@ func (rpc *ExampleServiceRPC) Version(ctx context.Context) (*Version, error) { func (s *ExampleServiceRPC) GetUser(ctx context.Context, header map[string]string, userID uint64) (*User, error) { if userID == 911 { - return nil, ErrorWithCause(ErrUserNotFound, fmt.Errorf("unknown user id %d", userID)) + return nil, ErrUserNotFound.WithCausef("unknown user id %d", userID) } if userID == 31337 { return nil, ErrUnauthorized @@ -91,14 +90,6 @@ func (s *ExampleServiceRPC) GetUser(ctx context.Context, header map[string]strin panic("oh no") } - // Legacy errors. - switch userID { - case 0: - return nil, Errorf(ErrInvalidArgument, "userId is required") - case 1000: - return nil, WrapError(ErrUnavailable, io.ErrUnexpectedEOF, "service unavailable") - } - return &User{ ID: userID, Username: "hihi", @@ -107,7 +98,7 @@ func (s *ExampleServiceRPC) GetUser(ctx context.Context, header map[string]strin func (rpc *ExampleServiceRPC) FindUser(ctx context.Context, s *SearchFilter) (string, *User, error) { if s == nil { - return "", nil, ErrorWithCause(ErrMissingArgument, fmt.Errorf("s search filter required")) + return "", nil, ErrMissingArgument.WithCausef("s search filter required") } name := s.Q return s.Q, &User{ From a0977ca3c87136cd70f8894af7d3c69b9ee25e5b Mon Sep 17 00:00:00 2001 From: Vojtech Vitek Date: Mon, 18 Nov 2024 15:25:50 +0100 Subject: [PATCH 3/3] Update golang-imports example --- _examples/golang-imports/api.gen.go | 93 +---------------------------- _examples/golang-imports/main.go | 2 +- 2 files changed, 2 insertions(+), 93 deletions(-) diff --git a/_examples/golang-imports/api.gen.go b/_examples/golang-imports/api.gen.go index 119edd7..e0de7db 100644 --- a/_examples/golang-imports/api.gen.go +++ b/_examples/golang-imports/api.gen.go @@ -2,7 +2,7 @@ // -- // Code generated by webrpc-gen@v0.21.0 with ../../../gen-golang generator. DO NOT EDIT. // -// webrpc-gen -schema=./proto/api.ridl -target=../../../gen-golang -out=./api.gen.go -pkg=main -server -client -legacyErrors=true -fmt=false +// webrpc-gen -schema=./proto/api.ridl -target=../../../gen-golang -out=./api.gen.go -pkg=main -server -client -fmt=false package main import ( @@ -678,9 +678,6 @@ func (e WebRPCError) Is(target error) bool { if rpcErr, ok := target.(WebRPCError); ok { return rpcErr.Code == e.Code } - if legacyErr, ok := target.(legacyError); ok { - return legacyErr.Code == e.Code - } return errors.Is(e.cause, target) } @@ -721,92 +718,4 @@ var ( ErrWebrpcClientDisconnected = WebRPCError{Code: -8, Name: "WebrpcClientDisconnected", Message: "client disconnected", HTTPStatus: 400} ErrWebrpcStreamLost = WebRPCError{Code: -9, Name: "WebrpcStreamLost", Message: "stream lost", HTTPStatus: 400} ErrWebrpcStreamFinished = WebRPCError{Code: -10, Name: "WebrpcStreamFinished", Message: "stream finished", HTTPStatus: 200} -) - -// -// Legacy errors -// - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func Errorf(err legacyError, format string, args ...interface{}) WebRPCError { - return err.WebRPCError.WithCausef(format, args...) -} - -// Deprecated: Use .WithCause() method on WebRPCError. -func WrapError(err legacyError, cause error, format string, args ...interface{}) WebRPCError { - return err.WebRPCError.WithCausef("%v: %w", fmt.Errorf(format, args...), cause) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func Failf(format string, args ...interface{}) WebRPCError { - return Errorf(ErrFail, format, args...) -} - -// Deprecated: Use .WithCause() method on WebRPCError. -func WrapFailf(cause error, format string, args ...interface{}) WebRPCError { - return WrapError(ErrFail, cause, format, args...) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorNotFound(format string, args ...interface{}) WebRPCError { - return Errorf(ErrNotFound, format, args...) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorInvalidArgument(argument string, validationMsg string) WebRPCError { - return Errorf(ErrInvalidArgument, argument+" "+validationMsg) -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorRequiredArgument(argument string) WebRPCError { - return ErrorInvalidArgument(argument, "is required") -} - -// Deprecated: Use fmt.Errorf() or WebRPCError. -func ErrorInternal(format string, args ...interface{}) WebRPCError { - return Errorf(ErrInternal, format, args...) -} - -type legacyError struct { WebRPCError } - -// Legacy errors (webrpc v0.10.0 and earlier). Will be removed. -var ( - // Deprecated. Define errors in RIDL schema. - ErrCanceled = legacyError{WebRPCError{Code: -10000, Name: "ErrCanceled", Message: "canceled", HTTPStatus: 408 /* RequestTimeout */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnknown = legacyError{WebRPCError{Code: -10001, Name: "ErrUnknown", Message: "unknown", HTTPStatus: 400 /* Bad Request */ }} - // Deprecated. Define errors in RIDL schema. - ErrFail = legacyError{WebRPCError{Code: -10002, Name: "ErrFail", Message: "fail", HTTPStatus: 422 /* Unprocessable Entity */ }} - // Deprecated. Define errors in RIDL schema. - ErrInvalidArgument = legacyError{WebRPCError{Code: -10003, Name: "ErrInvalidArgument", Message: "invalid argument", HTTPStatus: 400 /* BadRequest */ }} - // Deprecated. Define errors in RIDL schema. - ErrDeadlineExceeded = legacyError{WebRPCError{Code: -10004, Name: "ErrDeadlineExceeded", Message: "deadline exceeded", HTTPStatus: 408 /* RequestTimeout */ }} - // Deprecated. Define errors in RIDL schema. - ErrNotFound = legacyError{WebRPCError{Code: -10005, Name: "ErrNotFound", Message: "not found", HTTPStatus: 404 /* Not Found */ }} - // Deprecated. Define errors in RIDL schema. - ErrBadRoute = legacyError{WebRPCError{Code: -10006, Name: "ErrBadRoute", Message: "bad route", HTTPStatus: 404 /* Not Found */ }} - // Deprecated. Define errors in RIDL schema. - ErrAlreadyExists = legacyError{WebRPCError{Code: -10007, Name: "ErrAlreadyExists", Message: "already exists", HTTPStatus: 409 /* Conflict */ }} - // Deprecated. Define errors in RIDL schema. - ErrPermissionDenied = legacyError{WebRPCError{Code: -10008, Name: "ErrPermissionDenied", Message: "permission denied", HTTPStatus: 403 /* Forbidden */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnauthenticated = legacyError{WebRPCError{Code: -10009, Name: "ErrUnauthenticated", Message: "unauthenticated", HTTPStatus: 401 /* Unauthorized */ }} - // Deprecated. Define errors in RIDL schema. - ErrResourceExhausted = legacyError{WebRPCError{Code: -10010, Name: "ErrResourceExhausted", Message: "resource exhausted", HTTPStatus: 403 /* Forbidden */ }} - // Deprecated. Define errors in RIDL schema. - ErrFailedPrecondition = legacyError{WebRPCError{Code: -10011, Name: "ErrFailedPrecondition", Message: "failed precondition", HTTPStatus: 412 /* Precondition Failed */ }} - // Deprecated. Define errors in RIDL schema. - ErrAborted = legacyError{WebRPCError{Code: -10012, Name: "ErrAborted", Message: "aborted", HTTPStatus: 409 /* Conflict */ }} - // Deprecated. Define errors in RIDL schema. - ErrOutOfRange = legacyError{WebRPCError{Code: -10013, Name: "ErrOutOfRange", Message: "out of range", HTTPStatus: 400 /* Bad Request */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnimplemented = legacyError{WebRPCError{Code: -10014, Name: "ErrUnimplemented", Message: "unimplemented", HTTPStatus: 501 /* Not Implemented */ }} - // Deprecated. Define errors in RIDL schema. - ErrInternal = legacyError{WebRPCError{Code: -10015, Name: "ErrInternal", Message: "internal", HTTPStatus: 500 /* Internal Server Error */ }} - // Deprecated. Define errors in RIDL schema. - ErrUnavailable = legacyError{WebRPCError{Code: -10016, Name: "ErrUnavailable", Message: "unavailable", HTTPStatus: 503 /* Service Unavailable */ }} - // Deprecated. Define errors in RIDL schema. - ErrDataLoss = legacyError{WebRPCError{Code: -10017, Name: "ErrDataLoss", Message: "data loss", HTTPStatus: 500 /* Internal Server Error */ }} - // Deprecated. Define errors in RIDL schema. - ErrNone = legacyError{WebRPCError{Code: -10018, Name: "ErrNone", Message: "", HTTPStatus: 200 /* OK */ }} ) \ No newline at end of file diff --git a/_examples/golang-imports/main.go b/_examples/golang-imports/main.go index 36c2ff4..1e28953 100644 --- a/_examples/golang-imports/main.go +++ b/_examples/golang-imports/main.go @@ -1,6 +1,6 @@ package main -//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=./proto/api.ridl -target=../../../gen-golang -out=./api.gen.go -pkg=main -server -client -legacyErrors=true -fmt=false +//go:generate go run github.com/webrpc/webrpc/cmd/webrpc-gen -schema=./proto/api.ridl -target=../../../gen-golang -out=./api.gen.go -pkg=main -server -client -fmt=false import ( "context"