Skip to content
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

fix: remove catch binding #1459

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/events/http/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ export default class HttpServer {

try {
whatToLog = stringify(result)
} catch (error) {
} catch {
// nothing
} finally {
if (this.#options.printOutput) {
Expand Down
2 changes: 1 addition & 1 deletion src/events/http/createAuthScheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`,
Expand Down
2 changes: 1 addition & 1 deletion src/events/http/lambda-events/LambdaIntegrationEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 3 additions & 3 deletions src/events/http/lambda-events/LambdaProxyIntegrationEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -154,7 +154,7 @@ export default class LambdaProxyIntegrationEvent {
// claims = { ...claims }
// delete claims.scope
}
} catch (err) {
} catch {
// Do nothing
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -136,7 +136,7 @@ export default class LambdaProxyIntegrationEventV2 {
// claims = { ...claims }
// delete claims.scope
}
} catch (err) {
} catch {
// Do nothing
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/events/http/lambda-events/VelocityContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default class VelocityContext {
if (claims) {
assign(authorizer, { claims })
}
} catch (err) {
} catch {
// Nothing
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down
2 changes: 1 addition & 1 deletion src/events/websocket/WebSocketClients.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export default class WebSocketClients {

try {
json = parse(value)
} catch (err) {
} catch {
return DEFAULT_WEBSOCKETS_ROUTE
}

Expand Down
4 changes: 2 additions & 2 deletions src/events/websocket/WebSocketServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
Expand Down
6 changes: 3 additions & 3 deletions src/lambda/handler-runner/docker-runner/DockerContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions src/lambda/handler-runner/go-runner/GoRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class GoRunner {
async cleanup() {
try {
await rmdir(this.#tmpPath, { recursive: true })
} catch (e) {
} catch {
// @ignore
}

Expand All @@ -59,7 +59,7 @@ export default class GoRunner {
} else if (error) {
payload = error
}
} catch (err) {
} catch {
// @ignore
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)
}

Expand Down
4 changes: 2 additions & 2 deletions src/lambda/handler-runner/java-runner/JavaRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class JavaRunner {
try {
json = parse(item)
// nope, it's not JSON
} catch (err) {
} catch {
// no-op
}

Expand Down Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/lambda/handler-runner/python-runner/PythonRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class PythonRunner {
try {
json = parse(item)
// nope, it's not JSON
} catch (err) {
} catch {
// no-op
}

Expand Down
2 changes: 1 addition & 1 deletion src/lambda/handler-runner/ruby-runner/RubyRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class RubyRunner {
try {
json = parse(item)
// nope, it's not JSON
} catch (err) {
} catch {
// no-op
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/checkDockerDaemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/checkGoVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function checkGoVersion() {
if (stdout.match(/go1.\d+/g)) {
goVersion = '1.x'
}
} catch (err) {
} catch {
// @ignore
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/detectExecutable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion tests/_setupTeardown/npmInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const testFolders = [
async function detectDocker() {
try {
await checkDockerDaemon()
} catch (err) {
} catch {
return false
}
return true
Expand Down