Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
git-backup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
git-backup
Commits
7f72b67b
Commit
7f72b67b
authored
Jun 29, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
bf472763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
13 deletions
+33
-13
error.go
error.go
+5
-4
error_test.go
error_test.go
+28
-9
No files found.
error.go
View file @
7f72b67b
...
...
@@ -16,7 +16,6 @@ package main
import
(
"fmt"
"strings"
// "reflect"
)
// error type which is raised by raise(arg)
...
...
@@ -46,9 +45,11 @@ func raisef(format string, a ...interface{}) {
}
// raise if err != nil && err.value != nil
// XXX ^^^^^^^^^^^^^^^^^^^ do we need this?
// NOTE err can be != nil even if typed obj = nil (var obj *T; err = obj -> err != nil is true)
// raise if err != nil
// NOTE err can be != nil even if typed obj = nil:
// var obj *T;
// err = obj
// err != nil is true
func
raiseif
(
err
error
)
{
//if err != nil && !reflect.ValueOf(err).IsNil() {
if
err
!=
nil
{
...
...
error_test.go
View file @
7f72b67b
...
...
@@ -30,12 +30,6 @@ func TestErrRaiseCatch(t *testing.T) {
t
.
Fatal
(
"error not caught"
)
}
func
do_onunwind
()
{
defer
erronunwind
(
func
(
e
*
Error
)
*
Error
{
return
&
Error
{
2
,
e
}
})
do_raise1
()
}
// verify err chain has .arg(s) as expected
func
verifyErrChain
(
t
*
testing
.
T
,
e
*
Error
,
argv
...
interface
{})
{
...
...
@@ -53,15 +47,39 @@ func verifyErrChain(t *testing.T, e *Error, argv ...interface{}) {
}
}
func
do_onunwind1
(
t
*
testing
.
T
)
{
defer
erronunwind
(
func
(
e
*
Error
)
*
Error
{
t
.
Fatal
(
"on unwind called without raise"
)
return
nil
})
}
func
do_onunwind2
()
{
defer
erronunwind
(
func
(
e
*
Error
)
*
Error
{
return
&
Error
{
2
,
e
}
})
do_raise1
()
}
func
TestErrOnUnwind
(
t
*
testing
.
T
)
{
defer
errcatch
(
func
(
e
*
Error
)
{
verifyErrChain
(
t
,
e
,
2
,
1
)
})
do_onunwind
()
do_onunwind1
(
t
)
do_onunwind2
()
t
.
Fatal
(
"error not caught"
)
}
func
do_addcontext
()
{
func
do_addcontext1
(
t
*
testing
.
T
)
{
defer
erraddcontext
(
func
()
interface
{}
{
t
.
Fatal
(
"on addcontext called without raise"
)
return
nil
})
}
func
do_addcontext2
()
{
defer
erraddcontext
(
func
()
interface
{}
{
return
3
})
...
...
@@ -72,6 +90,7 @@ func TestErrAddContext(t *testing.T) {
defer
errcatch
(
func
(
e
*
Error
)
{
verifyErrChain
(
t
,
e
,
3
,
1
)
})
do_addcontext
()
do_addcontext1
(
t
)
do_addcontext2
()
t
.
Fatal
(
"error not caught"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment