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

Expose non-errors in informative way #6318

Merged
merged 2 commits into from Jul 1, 2019

Conversation

Projects
2 participants
@medikoo
Copy link
Member

commented Jun 28, 2019

Currently when non-error object is thrown, it's simply stringified, so it can be displayed as:

  Error --------------------------------------------------
 
  [object Object]
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace --------------------------------------------
 
Error: [object Object]
    at module.exports.logError (/Users/medikoo/npm-packages/serverless/lib/classes/Error.js:93:11)
    at /Users/medikoo/npm-packages/serverless/bin/serverless.js:69:9
    at processImmediate (internal/timers.js:439:21)
    at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
    at /Users/medikoo/npm-packages/serverless/bin/serverless.js:65:6
    at Object.<anonymous> (/Users/medikoo/npm-packages/serverless/bin/serverless.js:71:7)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11

Which hides real value being thrown, This patch fixes that and ensures real rejection objects are reported (e.g. Azure for some reason throws objects with meta data, and that patch ensures they're revealed)

After a patch we get reports as:

  Error --------------------------------------------------
 
  {
  Message: 'An error has occurred.',
  ExceptionMessage: "Runtime keys are stored on blob storage. This API doesn't support this " +
    'configuration. Please change Environment variable ' +
    "AzureWebJobsSecretStorageType value to 'Files'. For more info, visit " +
    'https://aka.ms/funcsecrets',
  ExceptionType: 'System.InvalidOperationException',
  StackTrace: '   at ' +
    'Kudu.Core.Functions.FunctionManager.<GetKeyObjectFromFile>d__9`1.MoveNext() ' +
    'in C:\\Kudu ' +
    'Files\\Private\\src\\master\\Kudu.Core\\Functions\\FunctionManager.cs:line 141\r' +
    '\n--- End of stack trace from previous location where exception was thrown ' +
    '---\r' +
    '\n   at ' +
    'System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r' +
    '\n   at ' +
    'System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task ' +
    'task)\r' +
    '\n   at ' +
    'Kudu.Core.Functions.FunctionManager.<GetMasterKeyAsync>d__11.MoveNext() ' +
    'in C:\\Kudu ' +
    'Files\\Private\\src\\master\\Kudu.Core\\Functions\\FunctionManager.cs:line 213\r' +
    '\n--- End of stack trace from previous location where exception was thrown ' +
    '---\r' +
    '\n   at ' +
    'System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r' +
    '\n   at ' +
    'System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task ' +
    'task)\r' +
    '\n   at ' +
    'Kudu.Services.Functions.FunctionController.<GetMasterKey>d__11.MoveNext() ' +
    'in C:\\Kudu ' +
    'Files\\Private\\src\\master\\Kudu.Services\\Functions\\FunctionController.cs:line ' +
    '121'
}
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
 
  Stack Trace -------------------

Is this ready for review?: YES
Is it a breaking change?: NO

medikoo added some commits Jun 28, 2019

@medikoo medikoo added this to the 1.47.0 milestone Jun 28, 2019

@medikoo medikoo self-assigned this Jun 28, 2019

@medikoo medikoo added this to In progress in Serverless via automation Jun 28, 2019

@medikoo medikoo changed the title Expose non-errors as is Expose non-errors in informative way Jun 28, 2019

@medikoo medikoo requested a review from pmuens Jun 28, 2019

Serverless automation moved this from In progress to Reviewer approved Jul 1, 2019

@pmuens

pmuens approved these changes Jul 1, 2019

Copy link
Member

left a comment

Makes sense! LGTM :shipit:

@medikoo medikoo merged commit 3b239a6 into master Jul 1, 2019

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
security/snyk - package.json (medikoo) No manifest changes detected

Serverless automation moved this from Reviewer approved to Done Jul 1, 2019

@medikoo medikoo deleted the fix-error-handling branch Jul 1, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.