dcbe2fc245
Currently, it's only possible to create modules at the leafs of the namespace structure. This CL lifts that restriction. Get rid of "use strict" in many cases.
31 lines
No EOL
1.1 KiB
JavaScript
31 lines
No EOL
1.1 KiB
JavaScript
Elm.Native.Error = {};
|
|
Elm.Native.Error.make = function(elm) {
|
|
elm.Native = elm.Native || {};
|
|
if (elm.Native.Error) return elm.Native.Error;
|
|
|
|
var fromString = Elm.Native.JavaScript.make(elm).fromString;
|
|
|
|
function indent(lines) {
|
|
var msg = '';
|
|
for (var i = 0; i < lines.length; ++i) {
|
|
msg += '<br/> ' + lines[i];
|
|
}
|
|
return msg;
|
|
}
|
|
|
|
function Case(moduleName, span) {
|
|
var msg = indent(['Non-exhaustive pattern match in case-expression.',
|
|
'Make sure your patterns cover every case!']);
|
|
throw new Error('Runtime error in module ' + moduleName + ' (' + span + '):' + msg);
|
|
}
|
|
|
|
function If(moduleName, span) {
|
|
var msg = indent(['Non-exhaustive pattern match in multi-way-if expression.',
|
|
'It is best to use \'otherwise\' as the last branch of multi-way-if.']);
|
|
throw new Error('Runtime error in module ' + moduleName + ' (' + span + '):' + msg);
|
|
}
|
|
|
|
function raise(str) { throw new Error(fromString(str)); }
|
|
|
|
return elm.Native.Error = { Case: Case, If: If, raise: raise };
|
|
}; |