-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: introduces MessageCarrier to simplify adding warnings and e…
…rrors (#141) Adds a message carrier class to handle collecting errors and warnings
- Loading branch information
1 parent
a29043a
commit 628d6c0
Showing
36 changed files
with
1,064 additions
and
955 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
'use strict'; | ||
|
||
module.exports = class MessageCarrier { | ||
constructor() { | ||
this._messages = { | ||
error: [], | ||
warning: [] | ||
}; | ||
} | ||
|
||
get messages() { | ||
return this._messages; | ||
} | ||
|
||
get errors() { | ||
return this._messages.error; | ||
} | ||
|
||
get warnings() { | ||
return this._messages.warning; | ||
} | ||
|
||
// status should be 'off', 'error', or 'warning' | ||
addMessage(path, message, status) { | ||
if (this._messages[status]) { | ||
this._messages[status].push({ | ||
path, | ||
message | ||
}); | ||
} | ||
} | ||
|
||
addMessageWithAuthId(path, message, authId, status) { | ||
if (this._messages[status]) { | ||
this._messages[status].push({ | ||
path, | ||
message, | ||
authId | ||
}); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.