Skip to content

Commit

Permalink
refactor: remove unnecessary else blocks after throws (#1317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Mar 12, 2023
1 parent 2b6897e commit e79699e
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 24 deletions.
5 changes: 2 additions & 3 deletions src/plugins/pdf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,11 @@ async function plugin(server, options) {
* Poppler will throw if the .pdf file provided
* by client is malformed, thus client error code
*/
/* istanbul ignore else: unable to test unknown errors */
if (/Syntax Error:/.test(err)) {
throw server.httpErrors.badRequest();
} else {
throw err;
}
/* istanbul ignore next: unable to test unknown errors */
throw err;
}

/**
Expand Down
10 changes: 4 additions & 6 deletions src/plugins/pdf-to-txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,11 @@ async function plugin(server, options) {
* Poppler will throw if the .pdf file provided
* by client is malformed, thus client error code
*/
/* istanbul ignore else: unable to test unknown errors */
if (/Syntax Error:/.test(err)) {
throw server.httpErrors.badRequest();
} else {
throw err;
}
/* istanbul ignore next: unable to test unknown errors */
throw err;
}

// glob sorts files alphabetically
Expand Down Expand Up @@ -194,12 +193,11 @@ async function plugin(server, options) {
* Poppler will throw if the .pdf file provided
* by client is malformed, thus client error code
*/
/* istanbul ignore else: unable to test unknown errors */
if (/Syntax Error:/.test(err)) {
throw server.httpErrors.badRequest();
} else {
throw err;
}
/* istanbul ignore next: unable to test unknown errors */
throw err;
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/plugins/rtf-to-html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,11 @@ async function plugin(server, options) {
* UnRTF will throw if the .rtf file provided
* by client is malformed, thus client error code
*/
/* istanbul ignore else: unable to test unknown errors */
if (/File is not the correct media type/.test(err)) {
throw server.httpErrors.badRequest();
} else {
throw err;
}
/* istanbul ignore next: unable to test unknown errors */
throw err;
}

res.type("text/html");
Expand Down
3 changes: 1 addition & 2 deletions src/routes/docx/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ async function route(server, options) {
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
) {
throw server.httpErrors.unsupportedMediaType();
} else {
return payload;
}
return payload;
}
);

Expand Down
3 changes: 1 addition & 2 deletions src/routes/docx/txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ async function route(server, options) {
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
) {
throw server.httpErrors.unsupportedMediaType();
} else {
return payload;
}
return payload;
}
);

Expand Down
3 changes: 1 addition & 2 deletions src/routes/pdf/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ async function route(server, options) {
results.mime !== "application/pdf"
) {
throw server.httpErrors.unsupportedMediaType();
} else {
return payload;
}
return payload;
}
);

Expand Down
3 changes: 1 addition & 2 deletions src/routes/pdf/txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ async function route(server, options) {
results.mime !== "application/pdf"
) {
throw server.httpErrors.unsupportedMediaType();
} else {
return payload;
}
return payload;
}
);

Expand Down
3 changes: 1 addition & 2 deletions src/routes/rtf/html/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ async function route(server, options) {
results.mime !== "application/rtf"
) {
throw server.httpErrors.unsupportedMediaType();
} else {
return payload;
}
return payload;
}
);

Expand Down
3 changes: 1 addition & 2 deletions src/routes/rtf/txt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ async function route(server, options) {
results.mime !== "application/rtf"
) {
throw server.httpErrors.unsupportedMediaType();
} else {
return payload;
}
return payload;
}
);

Expand Down

0 comments on commit e79699e

Please sign in to comment.