Skip to content

Don't panic in a lib #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,34 @@ func (this *Importer) ImportPage(pageno int, box string) int {
return tplN
}

func (this *Importer) ImportPageWithError(pageno int, box string) (int, error) {
// If page has already been imported, return existing tplN
pageNameNumber := fmt.Sprintf("%s-%04d", this.sourceFile, pageno)
if _, ok := this.importedPages[pageNameNumber]; ok {
return this.importedPages[pageNameNumber]
}

res, err := this.GetWriter().ImportPage(this.GetReader(), pageno, box)
if err != nil {
return 0, err
}

// Get current template id
tplN := this.tplN

// Set tpl info
this.tplMap[tplN] = &TplInfo{SourceFile: this.sourceFile, TemplateId: res, Writer: this.GetWriter()}

// Increment template id
this.tplN++

// Cache imported page tplN
this.importedPages[pageNameNumber] = tplN

return tplN
}


func (this *Importer) SetNextObjectID(objId int) {
this.GetWriter().SetNextObjectID(objId)
}
Expand Down