Avoid panic if printer is off or unreachable for some reason.
Closes #16 Closes #17 Closes #15
This commit was merged in pull request #18.
This commit is contained in:
@@ -2,14 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"ippserver/packages/ipp"
|
||||
"net/http"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func handleGetJobAttributes(r *ipp.Request, requestID uint32) *ipp.Response {
|
||||
func handleGetJobAttributes(r *ipp.Request, requestID uint32) (*ipp.Response, error) {
|
||||
|
||||
request := ipp.NewRequest(ipp.GetJobAttributes, requestID)
|
||||
request.AddOperatonAttribute(ipp.NewCharSetValue("attributes-charset", "utf-8"))
|
||||
@@ -26,7 +25,7 @@ func handleGetJobAttributes(r *ipp.Request, requestID uint32) *ipp.Response {
|
||||
|
||||
downStreamResponse, err := http.Post("http://"+"brn30055cb5e3ae.local:631/ipp/print", "application/ipp", b)
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rb := ipp.NewResponse(0, 0)
|
||||
@@ -42,5 +41,5 @@ func handleGetJobAttributes(r *ipp.Request, requestID uint32) *ipp.Response {
|
||||
response.AddJobAttribute(rb.GetAttribute("job-state"))
|
||||
response.AddJobAttribute(rb.GetAttribute("job-state-reasons"))
|
||||
|
||||
return response
|
||||
return response, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user