@atlaskit/pragmatic-drag-and-drop-react-beautiful-dnd-migration
Version:
An optional Pragmatic drag and drop package that enables rapid migration from react-beautiful-dnd to Pragmatic drag and drop
27 lines (26 loc) • 759 B
JavaScript
const isProduction = process.env.NODE_ENV === 'production';
const prefix = 'Invariant failed';
export class RbdInvariant extends Error {
constructor(message) {
super();
this.message = message;
}
toString() {
return this.message;
}
}
// A copy-paste of tiny-invariant but with a custom error type
// Throw an error if the condition fails
export function rbdInvariant(condition, message) {
if (condition) {
return;
}
if (isProduction) {
// In production we strip the message but still throw
throw new RbdInvariant(prefix);
} else {
// When not in production we allow the message to pass through
// *This block will be removed in production builds*
throw new RbdInvariant(`${prefix}: ${message || ''}`);
}
}