LiveRamp / reslang

A language for describing resource-oriented APIs & turning them into Swagger or resource diagrams. Oriented around the concepts we want to expose in the APIs.
Apache License 2.0
23 stars 7 forks source link

error handling emits stack trace to `stdout` #63

Closed j-q-arnold closed 4 years ago

j-q-arnold commented 4 years ago

When reslang encounters an error in the input spec, it can emit a stack trace to stdout. This could be useful for debugging or for a log file, but it isn't so useful in production. Standard error is redirected below to show stdout. When this output is combined with stderr, the result is pretty hard to read.

$ ./reslang ~/code/api-specs/segment-delivery --open 2>/dev/null
peg$SyntaxError: Expected "/*", "//", ":", or [ \t\r\n] but "\"" found.
    at peg$buildStructuredError (eval at compile (/Users/jaarno/code/reslang/node_modules/pegjs/lib/compiler/index.js:67:29), <anonymous>:608:14)
    at Object.peg$parse [as parse] (eval at compile (/Users/jaarno/code/reslang/node_modules/pegjs/lib/compiler/index.js:67:29), <anonymous>:5539:13)
    at Object.parseFile (/Users/jaarno/code/reslang/src/parse.ts:52:26)
    at SwagGen.BaseGen.processDefinition (/Users/jaarno/code/reslang/src/genbase.ts:95:31)
    at SwagGen.BaseGen.processDefinitions (/Users/jaarno/code/reslang/src/genbase.ts:62:18)
    at SwagGen.BaseGen (/Users/jaarno/code/reslang/src/genbase.ts:55:14)
    at new SwagGen (/Users/jaarno/code/reslang/src/genswagger.ts:26:42)
    at handle (/Users/jaarno/code/reslang/src/main.ts:184:26)
    at Object.<anonymous> (/Users/jaarno/code/reslang/src/main.ts:111:5)
    at Module._compile (internal/modules/cjs/loader.js:1176:30) {
  expected: [
    {
      type: 'class',
      parts: [Array],
      inverted: false,
      ignoreCase: false
    },
    {
      type: 'class',
      parts: [Array],
      inverted: false,
      ignoreCase: false
    },
    { type: 'literal', text: '//', ignoreCase: false },
    { type: 'literal', text: '/*', ignoreCase: false },
    { type: 'literal', text: ':', ignoreCase: false }
  ],
  found: '"',
  location: {
    start: { offset: 3527, line: 89, column: 5 },
    end: { offset: 3528, line: 89, column: 6 }
  }
}
liveandrew commented 4 years ago

@j-q-arnold hey jim - can you try with 1.4.8. i adjusted it about 3 weeks back to only send to stdout and only add stacktraces if --stacktrace option is present. i think it may be fixed, could you try and verify? i can't reproduce you example in the current release

j-q-arnold commented 4 years ago

Something is still broken, I think.

jaarno0218mac:reslang jaarno$ pwd
/Users/jaarno/code/reslang
jaarno0218mac:reslang jaarno$ git co master
Already on 'master'
Your branch is up to date with 'origin/master'.
jaarno0218mac:reslang jaarno$ git pull
Already up to date.
jaarno0218mac:reslang jaarno$ ./reslang --help

/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:434
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
src/names.ts:1:23 - error TS2307: Cannot find module 'pluralize' or its corresponding type declarations.

1 import pluralize from "pluralize"
                        ~~~~~~~~~~~

    at createTSError (/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:434:12)
    at reportTSError (/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:438:19)
    at getOutput (/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:578:36)
    at Object.compile (/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:775:32)
    at Module.m._compile (/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:858:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/jaarno/code/reslang/node_modules/ts-node/src/index.ts:861:12)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Module.require (internal/modules/cjs/loader.js:1080:19)
liveandrew commented 4 years ago

can you pls do "yarn install" after the pull, and try again?

j-q-arnold commented 4 years ago

The yarn install was the ticket. Much better now, without the stack dump. Thanks.

On Fri, Jun 26, 2020 at 11:48 AM liveandrew notifications@github.com wrote:

can you pls do "yarn install" after the pull, and try again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/LiveRamp/reslang/issues/63#issuecomment-650338890, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIYB46G625LYRCTIBGDSCWTRYTURPANCNFSM4OBCYYUQ .

liveandrew commented 4 years ago

thanks james!