added error signalling to NewMacroInjectTarget
This commit is contained in:
parent
95f8ec4c1c
commit
a1708563be
2
go.mod
2
go.mod
@ -1,3 +1,3 @@
|
|||||||
module Wordifier
|
module geniuscartel.xyz/wordifier
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package word
|
|||||||
import (
|
import (
|
||||||
zip2 "archive/zip"
|
zip2 "archive/zip"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
@ -16,11 +18,12 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMacroInjectTarget(name string, marker []byte, replacement []byte) MacroInjectTarget {
|
func NewMacroInjectTarget(name string, marker []byte, replacement []byte) (*MacroInjectTarget, error) {
|
||||||
if len(replacement) != len(marker) {
|
if len(replacement) != len(marker) {
|
||||||
panic("Payload and target are not the same size. Make sure replacement is the same length as marker")
|
err := errors.New(fmt.Sprintf("Payload[%d] and target[%d] are not the same size. Make sure replacement is the same length as marker", len(replacement), len(marker)))
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
return MacroInjectTarget{name, marker, replacement}
|
return &MacroInjectTarget{name, marker, replacement}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CopyZipWithReplacements(src string, dest io.Writer, replacements []MacroInjectTarget) {
|
func CopyZipWithReplacements(src string, dest io.Writer, replacements []MacroInjectTarget) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user