Skip to content

Commit

Permalink
refactor(Warning): add warning property checks
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-ciniawsky committed Aug 8, 2018
1 parent 95de4c1 commit 1f98aee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions src/Warning.js
Expand Up @@ -10,12 +10,19 @@
*/
class Warning extends Error {
constructor (warning) {
super()
super(warning)

const { text, line, column } = warning

this.name = 'LoaderWarning'
this.message = `\n(${line}:${column}) ${text}\n`
this.name = 'Warning'

this.message = `${this.name}\n\n`

if (typeof line !== 'undefined') {
this.message += `(${line}:${column}) `
}

this.message += `${text}`

this.stack = false
}
Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/Warnings.test.js.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Warnings Plugins 1`] = `
"
(1:5) <Message>
"
"Warning
(1:5) <Message>"
`;

0 comments on commit 1f98aee

Please sign in to comment.