This commit is contained in:
parent
3755f0fe03
commit
292866bcf9
|
@ -37,7 +37,6 @@ refreshRate: 1000
|
|||
Exec
|
||||
```
|
||||
> docker run --name printnatura -it --rm -v $PWD/config.local.yml:/printnatura/config.local.yml:ro -v $PWD/cupsd.conf:/etc/cups/cupsd.conf:ro -p 80:631 printnatura
|
||||
|
||||
```
|
||||
|
||||
Bash
|
||||
|
|
|
@ -239,7 +239,7 @@ class PrintServer {
|
|||
|
||||
// Request
|
||||
let pdfData;
|
||||
for (let attempts = 0; !pdfData && attempts < 2; attempts++) {
|
||||
for (let attempts = 0; !pdfData && attempts < 3; attempts++) {
|
||||
try {
|
||||
const res = await this.api({
|
||||
method: 'get',
|
||||
|
@ -250,21 +250,28 @@ class PrintServer {
|
|||
pdfData = res.data;
|
||||
}
|
||||
catch (err) {
|
||||
if (err.name === 'AxiosError' && err.code === 'ERR_BAD_REQUEST') {
|
||||
if (err.name === 'AxiosError') {
|
||||
const res = err.response;
|
||||
if (res.status === 401) { // Unauthorized
|
||||
await this.getToken();
|
||||
} else {
|
||||
const resMessage = JSON.parse(res.data).error.message;
|
||||
const resErr = new Error(`${err.message}: ${resMessage}`);
|
||||
resErr.stack = err.stack;
|
||||
throw resErr;
|
||||
switch(res.status) {
|
||||
case 401: // Unauthorized
|
||||
await this.getToken();
|
||||
break;
|
||||
case 502 || 504: // Bad Gateway & Gateway Timeout
|
||||
break;
|
||||
default:
|
||||
const resMessage = JSON.parse(res.data).error.message;
|
||||
const resErr = new Error(`${err.message}: ${resMessage}`);
|
||||
resErr.stack = err.stack;
|
||||
throw resErr;
|
||||
}
|
||||
} else
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pdfData)
|
||||
throw 'Could not get pdf from server'
|
||||
|
||||
// Save PDF to disk
|
||||
const printer = jobData.printer;
|
||||
const tmpPath = conf.tmpDir;
|
||||
|
|
Loading…
Reference in New Issue