Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add keys generate command #1695

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

Closed
umbynos wants to merge 5 commits into master from umbynos/keys_generate_command
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor TempFileCreationFailedError to be FileCreationFailedError
  • Loading branch information
umbynos committed Mar 24, 2022
commit f014be13bbd707b9a43aae726ec329325b9f966f
15 changes: 8 additions & 7 deletions arduino/errors.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -698,21 +698,22 @@ func (e *TempDirCreationFailedError) ToRPCStatus() *status.Status {
return status.New(codes.Unavailable, e.Error())
}

// TempFileCreationFailedError is returned if a temp file could not be created
type TempFileCreationFailedError struct {
Cause error
// FileCreationFailedError is returned if a temp file could not be created
type FileCreationFailedError struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is an exported object, this will be a breaking change and so the standard procedure should be followed to communicate that to the users.

umbynos reacted with thumbs up emoji
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not though about it, but you are right

Message string
Cause error
}

func (e *TempFileCreationFailedError) Error() string {
return composeErrorMsg(tr("Cannot create temp file"), e.Cause)
func (e *FileCreationFailedError) Error() string {
return composeErrorMsg(e.Message, e.Cause)
}

func (e *TempFileCreationFailedError) Unwrap() error {
func (e *FileCreationFailedError) Unwrap() error {
return e.Cause
}

// ToRPCStatus converts the error into a *status.Status
func (e *TempFileCreationFailedError) ToRPCStatus() *status.Status {
func (e *FileCreationFailedError) ToRPCStatus() *status.Status {
return status.New(codes.Unavailable, e.Error())
}

Expand Down
8 changes: 4 additions & 4 deletions commands/instances.go
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,9 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB Do

var tmp *paths.Path
if tmpFile, err := ioutil.TempFile("", ""); err != nil {
return nil, &arduino.TempFileCreationFailedError{Cause: err}
return nil, &arduino.FileCreationFailedError{Message: tr("Cannot create temp file"), Cause: err}
} else if err := tmpFile.Close(); err != nil {
return nil, &arduino.TempFileCreationFailedError{Cause: err}
return nil, &arduino.FileCreationFailedError{Message: tr("Cannot create temp file"), Cause: err}
} else {
tmp = paths.New(tmpFile.Name())
}
Expand Down Expand Up @@ -502,9 +502,9 @@ func UpdateIndex(ctx context.Context, req *rpc.UpdateIndexRequest, downloadCB Do
URLSig.Path += ".sig"

if t, err := ioutil.TempFile("", ""); err != nil {
return nil, &arduino.TempFileCreationFailedError{Cause: err}
return nil, &arduino.FileCreationFailedError{Message: tr("Cannot create temp file"), Cause: err}
} else if err := t.Close(); err != nil {
return nil, &arduino.TempFileCreationFailedError{Cause: err}
return nil, &arduino.FileCreationFailedError{Message: tr("Cannot create temp file"), Cause: err}
} else {
tmpSig = paths.New(t.Name())
}
Expand Down

AltStyle によって変換されたページ (->オリジナル) /