Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beaver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orus-io
beaver
Commits
659de86e0598
Commit
659de86e0598
authored
2 years ago
by
steeve.chailloux
Browse files
Options
Downloads
Patches
Plain Diff
pretty print error messages
parent
dcf933cad0a6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#36104
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
runner/cmd.go
+4
-2
4 additions, 2 deletions
runner/cmd.go
runner/main.go
+6
-0
6 additions, 0 deletions
runner/main.go
with
10 additions
and
2 deletions
runner/cmd.go
+
4
−
2
View file @
659de86e
package
runner
import
(
"fmt"
"github.com/go-cmd/cmd"
)
func
RunCMD
(
c
*
cmd
.
Cmd
)
(
err
error
,
stdout
,
stderr
[]
string
)
{
statusChan
:=
c
.
Start
()
status
:=
<-
statusChan
...
...
@@ -4,11 +6,11 @@
"github.com/go-cmd/cmd"
)
func
RunCMD
(
c
*
cmd
.
Cmd
)
(
err
error
,
stdout
,
stderr
[]
string
)
{
statusChan
:=
c
.
Start
()
status
:=
<-
statusChan
if
status
.
Error
!=
nil
{
return
err
,
status
.
Stdout
,
status
.
Stderr
if
status
.
Error
!=
nil
||
status
.
Exit
>
0
{
return
fmt
.
Errorf
(
"Cannot execute command: %w"
,
err
)
,
status
.
Stdout
,
status
.
Stderr
}
stdout
=
status
.
Stdout
stderr
=
status
.
Stderr
...
...
This diff is collapsed.
Click to expand it.
runner/main.go
+
6
−
0
View file @
659de86e
...
...
@@ -67,6 +67,9 @@
Str
(
"stderr"
,
strings
.
Join
(
stdErr
,
"
\n
"
))
.
Msg
(
"failed to run command"
)
// TODO: print error to stderr
// Error must be pretty printed to end users /!\
fmt
.
Printf
(
"
\n
%s
\n\n
"
,
strings
.
Join
(
stdErr
,
"
\n
"
))
return
fmt
.
Errorf
(
"failed to run command: %w"
,
err
)
}
if
tmpFile
,
err
:=
ioutil
.
TempFile
(
tmpDir
,
fmt
.
Sprintf
(
"compiled-%s-"
,
name
));
err
!=
nil
{
...
...
@@ -101,6 +104,9 @@
Str
(
"stderr"
,
strings
.
Join
(
stdErr
,
"
\n
"
))
.
Msg
(
"failed to run command"
)
// TODO: print error to stderr
// Error message must be pretty printed to end users
fmt
.
Printf
(
"
\n
%s
\n\n
"
,
strings
.
Join
(
stdErr
,
"
\n
"
))
return
fmt
.
Errorf
(
"failed to run command: %w"
,
err
)
}
if
tmpFile
,
err
:=
ioutil
.
TempFile
(
tmpDir
,
"fully-compiled-"
);
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment