1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-07-31 04:20:26 +02:00

Add utils/warning.js

This commit is contained in:
Samy Pesse
2016-10-22 00:36:42 +02:00
parent 8ed3f12aba
commit 1dbc90604d

29
src/utils/warning.js Normal file
View File

@@ -0,0 +1,29 @@
const __DEV__ = (
typeof process !== 'undefined' &&
process.env &&
process.env.NODE_ENV !== 'production'
)
/**
* Log a development warning.
* @param {String} message
*/
export default function warning(message) {
if (!__DEV__) {
return
}
if (typeof console !== 'undefined') {
console.error('Warning: ', message) // eslint-disable-line no-console
}
try {
// --- Welcome to debugging Slate ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message)
} catch (x) {
// This error is only for debugging
}
}