2013-09-30 07:44:31 +00:00
|
|
|
Elm.Native.Error = {};
|
|
|
|
Elm.Native.Error.make = function(elm) {
|
2013-03-10 03:02:07 +00:00
|
|
|
elm.Native = elm.Native || {};
|
2013-09-30 08:32:27 +00:00
|
|
|
elm.Native.Error = elm.Native.Error || {};
|
|
|
|
if (elm.Native.Error.values) return elm.Native.Error.values;
|
2013-03-10 03:02:07 +00:00
|
|
|
|
2013-09-30 07:44:31 +00:00
|
|
|
var fromString = Elm.Native.JavaScript.make(elm).fromString;
|
2013-03-12 07:48:11 +00:00
|
|
|
|
2013-08-04 20:47:27 +00:00
|
|
|
function indent(lines) {
|
|
|
|
var msg = '';
|
|
|
|
for (var i = 0; i < lines.length; ++i) {
|
|
|
|
msg += '<br/> ' + lines[i];
|
|
|
|
}
|
|
|
|
return msg;
|
|
|
|
}
|
|
|
|
|
2013-08-04 19:51:52 +00:00
|
|
|
function Case(moduleName, span) {
|
2013-08-04 20:47:27 +00:00
|
|
|
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);
|
2013-03-05 18:06:52 +00:00
|
|
|
}
|
2013-03-10 03:02:07 +00:00
|
|
|
|
2013-08-04 19:51:52 +00:00
|
|
|
function If(moduleName, span) {
|
2013-08-04 20:47:27 +00:00
|
|
|
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);
|
2013-03-05 18:06:52 +00:00
|
|
|
}
|
2013-03-10 03:02:07 +00:00
|
|
|
|
2013-03-12 07:48:11 +00:00
|
|
|
function raise(str) { throw new Error(fromString(str)); }
|
|
|
|
|
2013-09-30 08:32:27 +00:00
|
|
|
return elm.Native.Error.values = { Case: Case, If: If, raise: raise };
|
2013-03-05 18:06:52 +00:00
|
|
|
};
|