about summary refs log tree commit diff stats
path: root/internal/config/cspgenerator.go
diff options
context:
space:
mode:
authorAlan Pearce2024-11-28 15:12:00 +0100
committerAlan Pearce2024-11-28 15:12:00 +0100
commitb94f66cfe5bf87ec6d2a32448ca5c55ba118c7aa (patch)
treeeb6f951b3a0959c6ace7be6f111124791e90c54d /internal/config/cspgenerator.go
parent183b0c8b5edbcf4224d4dd3905ca483204522656 (diff)
downloadwebsite-b94f66cfe5bf87ec6d2a32448ca5c55ba118c7aa.tar.lz
website-b94f66cfe5bf87ec6d2a32448ca5c55ba118c7aa.tar.zst
website-b94f66cfe5bf87ec6d2a32448ca5c55ba118c7aa.zip
Use errors.WithMessage in place of .Wrap HEAD main
Diffstat (limited to 'internal/config/cspgenerator.go')
-rw-r--r--internal/config/cspgenerator.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/internal/config/cspgenerator.go b/internal/config/cspgenerator.go
index 9974819..389e778 100644
--- a/internal/config/cspgenerator.go
+++ b/internal/config/cspgenerator.go
@@ -17,7 +17,7 @@ func GenerateCSP() error {
 	file, err := os.OpenFile("./csp.go", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0)
 	if err != nil {
 
-		return errors.Wrap(err, "could not write to output")
+		return errors.WithMessage(err, "could not write to output")
 	}
 	defer file.Close()
 
@@ -32,12 +32,12 @@ import (
 `)
 	if err != nil {
 
-		return errors.Wrap(err, "could not write to output")
+		return errors.WithMessage(err, "could not write to output")
 	}
 
 	_, err = fmt.Fprintf(file, "type CSP struct {\n")
 	if err != nil {
-		return errors.Wrap(err, "could not write to output")
+		return errors.WithMessage(err, "could not write to output")
 	}
 
 	for i := 0; i < t.NumField(); i++ {
@@ -46,28 +46,28 @@ import (
 		t = field.Type
 		tags, err := structtag.Parse(string(field.Tag))
 		if err != nil {
-			return errors.Wrap(err, "could not write to output")
+			return errors.WithMessage(err, "could not write to output")
 		}
 		cspTag, err := tags.Get("csp")
 		if err != nil {
-			return errors.Wrap(err, "could not get csp tag")
+			return errors.WithMessage(err, "could not get csp tag")
 		}
 		err = tags.Set(&structtag.Tag{
 			Key:  "toml",
 			Name: cspTag.Name,
 		})
 		if err != nil {
-			return errors.Wrap(err, "could not set toml tag")
+			return errors.WithMessage(err, "could not set toml tag")
 		}
 
 		_, err = fmt.Fprintf(file, "\t%-23s %-28s `%s`\n", field.Name, t, tags.String())
 		if err != nil {
-			return errors.Wrap(err, "could not write to output")
+			return errors.WithMessage(err, "could not write to output")
 		}
 	}
 	_, err = fmt.Fprintln(file, "}")
 	if err != nil {
-		return errors.Wrap(err, "could not write to output")
+		return errors.WithMessage(err, "could not write to output")
 	}
 
 	_, err = fmt.Fprintln(file, `
@@ -75,7 +75,7 @@ func (c *CSP) String() string {
 	return csp.Header(*c).String()
 }`)
 	if err != nil {
-		return errors.Wrap(err, "could not write to output")
+		return errors.WithMessage(err, "could not write to output")
 	}
 
 	return nil