diff --git a/src/events/http/HttpServer.js b/src/events/http/HttpServer.js index 5ac7c0624..223745512 100644 --- a/src/events/http/HttpServer.js +++ b/src/events/http/HttpServer.js @@ -1244,7 +1244,7 @@ export default class HttpServer { try { whatToLog = stringify(result) - } catch (error) { + } catch { // nothing } finally { if (this.#options.printOutput) { diff --git a/src/events/http/createAuthScheme.js b/src/events/http/createAuthScheme.js index ea5863b94..127b9cddc 100644 --- a/src/events/http/createAuthScheme.js +++ b/src/events/http/createAuthScheme.js @@ -199,7 +199,7 @@ export default function createAuthScheme( usageIdentifierKey: result.usageIdentifierKey, }, }) - } catch (err) { + } catch { if (log) { log.notice( `Authorization function returned an error response: (λ: ${authFunName})`, diff --git a/src/events/http/lambda-events/LambdaIntegrationEvent.js b/src/events/http/lambda-events/LambdaIntegrationEvent.js index bb0596924..a0b475d7b 100644 --- a/src/events/http/lambda-events/LambdaIntegrationEvent.js +++ b/src/events/http/lambda-events/LambdaIntegrationEvent.js @@ -30,7 +30,7 @@ export default class LambdaIntegrationEvent { }, } } - } catch (error) { + } catch { if (this.log) { this.log.error( 'Could not parse process.env.AUTHORIZER, make sure it is correct JSON', diff --git a/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js b/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js index 7fc4a02d6..4d662d7f0 100644 --- a/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js +++ b/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js @@ -66,7 +66,7 @@ export default class LambdaProxyIntegrationEvent { if (env.AUTHORIZER) { try { authAuthorizer = parse(env.AUTHORIZER) - } catch (error) { + } catch { if (this.log) { this.log.error( 'Could not parse env.AUTHORIZER, make sure it is correct JSON', @@ -89,7 +89,7 @@ export default class LambdaProxyIntegrationEvent { if (headers['sls-offline-authorizer-override']) { try { authAuthorizer = parse(headers['sls-offline-authorizer-override']) - } catch (error) { + } catch { if (this.log) { this.log.error( 'Could not parse header sls-offline-authorizer-override, make sure it is correct JSON', @@ -154,7 +154,7 @@ export default class LambdaProxyIntegrationEvent { // claims = { ...claims } // delete claims.scope } - } catch (err) { + } catch { // Do nothing } } diff --git a/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js b/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js index 7caf80d08..3fb4a21b6 100644 --- a/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js +++ b/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js @@ -54,7 +54,7 @@ export default class LambdaProxyIntegrationEventV2 { if (env.AUTHORIZER) { try { authAuthorizer = parse(env.AUTHORIZER) - } catch (error) { + } catch { if (this.log) { this.log.error( 'Could not parse process.env.AUTHORIZER, make sure it is correct JSON', @@ -77,7 +77,7 @@ export default class LambdaProxyIntegrationEventV2 { if (headers['sls-offline-authorizer-override']) { try { authAuthorizer = parse(headers['sls-offline-authorizer-override']) - } catch (error) { + } catch { if (this.log) { this.log.error( 'Could not parse header sls-offline-authorizer-override, make sure it is correct JSON', @@ -136,7 +136,7 @@ export default class LambdaProxyIntegrationEventV2 { // claims = { ...claims } // delete claims.scope } - } catch (err) { + } catch { // Do nothing } } diff --git a/src/events/http/lambda-events/VelocityContext.js b/src/events/http/lambda-events/VelocityContext.js index 2939aede8..b4f06c269 100644 --- a/src/events/http/lambda-events/VelocityContext.js +++ b/src/events/http/lambda-events/VelocityContext.js @@ -84,7 +84,7 @@ export default class VelocityContext { if (claims) { assign(authorizer, { claims }) } - } catch (err) { + } catch { // Nothing } } diff --git a/src/events/http/lambda-events/renderVelocityTemplateObject.js b/src/events/http/lambda-events/renderVelocityTemplateObject.js index d98448157..ccf74a6b4 100644 --- a/src/events/http/lambda-events/renderVelocityTemplateObject.js +++ b/src/events/http/lambda-events/renderVelocityTemplateObject.js @@ -10,7 +10,7 @@ function tryToParseJSON(string) { let parsed try { parsed = parse(string) - } catch (err) { + } catch { // nothing! Some things are not meant to be parsed. } diff --git a/src/events/websocket/WebSocketClients.js b/src/events/websocket/WebSocketClients.js index e331ecff8..de17dbeb1 100644 --- a/src/events/websocket/WebSocketClients.js +++ b/src/events/websocket/WebSocketClients.js @@ -327,7 +327,7 @@ export default class WebSocketClients { try { json = parse(value) - } catch (err) { + } catch { return DEFAULT_WEBSOCKETS_ROUTE } diff --git a/src/events/websocket/WebSocketServer.js b/src/events/websocket/WebSocketServer.js index 92b32c082..19417cecc 100644 --- a/src/events/websocket/WebSocketServer.js +++ b/src/events/websocket/WebSocketServer.js @@ -43,8 +43,8 @@ export default class WebSocketServer { return } cb(true) - } catch (e) { - debugLog(`Error verifying`, e) + } catch (err) { + debugLog(`Error verifying`, err) cb(false) } }) diff --git a/src/lambda/handler-runner/docker-runner/DockerContainer.js b/src/lambda/handler-runner/docker-runner/DockerContainer.js index 198fa8048..7209b42e3 100644 --- a/src/lambda/handler-runner/docker-runner/DockerContainer.js +++ b/src/lambda/handler-runner/docker-runner/DockerContainer.js @@ -276,11 +276,11 @@ export default class DockerContainer { try { layer = await this.#lambda.getLayerVersionByArn(params).promise() - } catch (e) { + } catch (err) { if (this.log) { - this.log.warning(`[${layerName}] ${e.code}: ${e.message}`) + this.log.warning(`[${layerName}] ${err.code}: ${err.message}`) } else { - logWarning(`[${layerName}] ${e.code}: ${e.message}`) + logWarning(`[${layerName}] ${err.code}: ${err.message}`) } return } diff --git a/src/lambda/handler-runner/go-runner/GoRunner.js b/src/lambda/handler-runner/go-runner/GoRunner.js index a59b6bf02..653702ceb 100644 --- a/src/lambda/handler-runner/go-runner/GoRunner.js +++ b/src/lambda/handler-runner/go-runner/GoRunner.js @@ -34,7 +34,7 @@ export default class GoRunner { async cleanup() { try { await rmdir(this.#tmpPath, { recursive: true }) - } catch (e) { + } catch { // @ignore } @@ -59,7 +59,7 @@ export default class GoRunner { } else if (error) { payload = error } - } catch (err) { + } catch { // @ignore } } diff --git a/src/lambda/handler-runner/in-process-runner/InProcessRunner.js b/src/lambda/handler-runner/in-process-runner/InProcessRunner.js index 05c2bb702..65d8410e5 100644 --- a/src/lambda/handler-runner/in-process-runner/InProcessRunner.js +++ b/src/lambda/handler-runner/in-process-runner/InProcessRunner.js @@ -105,7 +105,7 @@ export default class InProcessRunner { // execute (run) handler try { result = handler(event, lambdaContext, callback) - } catch (err) { + } catch { throw new Error(`Uncaught error in '${this.#functionKey}' handler.`) } diff --git a/src/lambda/handler-runner/java-runner/JavaRunner.js b/src/lambda/handler-runner/java-runner/JavaRunner.js index f0fdf7d74..9aecc1992 100644 --- a/src/lambda/handler-runner/java-runner/JavaRunner.js +++ b/src/lambda/handler-runner/java-runner/JavaRunner.js @@ -43,7 +43,7 @@ export default class JavaRunner { try { json = parse(item) // nope, it's not JSON - } catch (err) { + } catch { // no-op } @@ -90,7 +90,7 @@ export default class JavaRunner { httpOptions, ) result = await response.text() - } catch (e) { + } catch { if (this.log) { this.log.notice( 'Local java server not running. For faster local invocations, run "java-invoke-local --server" in your project directory', diff --git a/src/lambda/handler-runner/python-runner/PythonRunner.js b/src/lambda/handler-runner/python-runner/PythonRunner.js index 2e87f90ee..66b1d42af 100644 --- a/src/lambda/handler-runner/python-runner/PythonRunner.js +++ b/src/lambda/handler-runner/python-runner/PythonRunner.js @@ -76,7 +76,7 @@ export default class PythonRunner { try { json = parse(item) // nope, it's not JSON - } catch (err) { + } catch { // no-op } diff --git a/src/lambda/handler-runner/ruby-runner/RubyRunner.js b/src/lambda/handler-runner/ruby-runner/RubyRunner.js index 67545d3be..dce75fe8c 100644 --- a/src/lambda/handler-runner/ruby-runner/RubyRunner.js +++ b/src/lambda/handler-runner/ruby-runner/RubyRunner.js @@ -42,7 +42,7 @@ export default class RubyRunner { try { json = parse(item) // nope, it's not JSON - } catch (err) { + } catch { // no-op } diff --git a/src/utils/checkDockerDaemon.js b/src/utils/checkDockerDaemon.js index 4360a1e1c..2178b38ae 100644 --- a/src/utils/checkDockerDaemon.js +++ b/src/utils/checkDockerDaemon.js @@ -9,7 +9,7 @@ export default async function checkDockerDaemon() { '{{.Server.Os}}', ]) dockerServerOS = stdout - } catch (err) { + } catch { throw new Error('The docker daemon is not running.') } diff --git a/src/utils/checkGoVersion.js b/src/utils/checkGoVersion.js index 388bd1ea6..97f363653 100644 --- a/src/utils/checkGoVersion.js +++ b/src/utils/checkGoVersion.js @@ -8,7 +8,7 @@ export default async function checkGoVersion() { if (stdout.match(/go1.\d+/g)) { goVersion = '1.x' } - } catch (err) { + } catch { // @ignore } diff --git a/src/utils/detectExecutable.js b/src/utils/detectExecutable.js index 504367604..12c7981e0 100644 --- a/src/utils/detectExecutable.js +++ b/src/utils/detectExecutable.js @@ -5,7 +5,7 @@ export default async function detectExecutable(exe, versionFlag = '--version') { const { failed } = await execa(exe, [versionFlag]) return failed === false - } catch (err) { + } catch { return false } } diff --git a/tests/_setupTeardown/npmInstall.js b/tests/_setupTeardown/npmInstall.js index c0451c3b4..659730eb8 100644 --- a/tests/_setupTeardown/npmInstall.js +++ b/tests/_setupTeardown/npmInstall.js @@ -22,7 +22,7 @@ const testFolders = [ async function detectDocker() { try { await checkDockerDaemon() - } catch (err) { + } catch { return false } return true