added error signalling to NewMacroInjectTarget
This commit is contained in:
parent
95f8ec4c1c
commit
a1708563be
@ -3,6 +3,8 @@ package word
|
||||
import (
|
||||
zip2 "archive/zip"
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"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) {
|
||||
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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user