Skip to content

Commit

Permalink
feat: add custom error type for parser
Browse files Browse the repository at this point in the history
  • Loading branch information
d-strobel committed Nov 13, 2023
1 parent 3466dac commit 4798e03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions winerror/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
ConfigError = "configuration_error"
ConnectionError = "connection_error"
WindowsError = "windows_error"
ParserError = "parser_error"
)

// Error type for gowindows
Expand Down
9 changes: 9 additions & 0 deletions winerror/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,14 @@ func TestErrorf(t *testing.T) {
if winErr.Error() != expectedResult {
t.Errorf("Expected error message: '%s'\nGot: '%s'", expectedResult, winErr.Error())
}

// ParserError
root = ParserError
expectedResult = "[parser_error] Sample error message"
winErr = Errorf(root, msg)

if winErr.Error() != expectedResult {
t.Errorf("Expected error message: '%s'\nGot: '%s'", expectedResult, winErr.Error())
}
})
}

0 comments on commit 4798e03

Please sign in to comment.