Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Configuration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Go
Application
Configuration
Commits
bd2c76a5
Verified
Commit
bd2c76a5
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix:
#6
parent
8b0d5f5b
Branches
Branches containing commit
Tags
v1.18.0
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
change-handler.go
+3
-3
3 additions, 3 deletions
change-handler.go
error-handler.go
+19
-4
19 additions, 4 deletions
error-handler.go
error.go
+2
-2
2 additions, 2 deletions
error.go
postprocessing-handler.go
+3
-3
3 additions, 3 deletions
postprocessing-handler.go
with
27 additions
and
12 deletions
change-handler.go
+
3
−
3
View file @
bd2c76a5
...
...
@@ -22,13 +22,13 @@ func (s *Settings[C]) OnChange(hook ChangeHook) *Settings[C] {
}
// HasOnChangeHook returns true if there are registered hooks.
func
(
s
*
Settings
[
C
])
HasOnChangeHook
(
hook
ChangeHook
)
*
Settings
[
C
]
{
func
(
s
*
Settings
[
C
])
HasOnChangeHook
(
hook
ChangeHook
)
bool
{
for
_
,
h
:=
range
s
.
hooks
.
change
{
if
h
==
hook
{
b
re
ak
re
turn
true
}
}
return
s
return
false
}
// RemoveOnChangeHook removes a change hook from the list of hooks.
...
...
This diff is collapsed.
Click to expand it.
error-handler.go
+
19
−
4
View file @
bd2c76a5
...
...
@@ -18,13 +18,13 @@ func (s *Settings[C]) OnError(hook ErrorHook) *Settings[C] {
}
// HasOnErrorHook returns true if there are registered hooks.
func
(
s
*
Settings
[
C
])
HasOnErrorHook
(
hook
ErrorHook
)
*
Settings
[
C
]
{
func
(
s
*
Settings
[
C
])
HasOnErrorHook
(
hook
ErrorHook
)
bool
{
for
_
,
h
:=
range
s
.
hooks
.
error
{
if
h
==
hook
{
b
re
ak
re
turn
true
}
}
return
s
return
false
}
// RemoveOnErrorHook removes a change hook from the list of hooks.
...
...
@@ -39,8 +39,23 @@ func (s *Settings[C]) RemoveOnErrorHook(hook ErrorHook) *Settings[C] {
}
func
(
s
*
Settings
[
C
])
notifyErrorHooks
()
*
Settings
[
C
]
{
if
len
(
s
.
errors
)
==
0
{
return
s
}
if
len
(
s
.
hooks
.
error
)
==
0
{
return
s
}
errors
:=
make
([]
error
,
len
(
s
.
errors
))
copy
(
errors
,
s
.
Errors
())
s
.
ResetErrors
()
for
_
,
h
:=
range
s
.
hooks
.
error
{
go
h
.
Handle
(
ErrorEvent
{})
go
h
.
Handle
(
ErrorEvent
{
Errors
:
errors
,
})
}
return
s
}
This diff is collapsed.
Click to expand it.
error.go
+
2
−
2
View file @
bd2c76a5
...
...
@@ -8,14 +8,14 @@ import (
"reflect"
)
// ResetError is used to reset the error to nil
// ResetError
s
is used to reset the error to nil
// After calling this function, the call HasErrors() will return false
func
(
s
*
Settings
[
C
])
ResetErrors
()
*
Settings
[
C
]
{
s
.
errors
=
[]
error
{}
return
s
}
//
C
heck if the setting contains errors
//
HasErrors c
heck
s
if the setting contains errors
func
(
s
*
Settings
[
C
])
HasErrors
()
bool
{
return
len
(
s
.
errors
)
>
0
}
...
...
This diff is collapsed.
Click to expand it.
postprocessing-handler.go
+
3
−
3
View file @
bd2c76a5
...
...
@@ -22,13 +22,13 @@ func (s *Settings[C]) OnPostprocessing(hook PostprocessingHook) *Settings[C] {
}
// HasOnPostprocessingHook returns true if there are registered hooks.
func
(
s
*
Settings
[
C
])
HasOnPostprocessingHook
(
hook
PostprocessingHook
)
*
Settings
[
C
]
{
func
(
s
*
Settings
[
C
])
HasOnPostprocessingHook
(
hook
PostprocessingHook
)
bool
{
for
_
,
h
:=
range
s
.
hooks
.
postprocessing
{
if
h
==
hook
{
b
re
ak
re
turn
true
}
}
return
s
return
false
}
// RemoveOnPostprocessingHook removes a change hook from the list of hooks.
...
...
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