解析するエラーメッセージの配列を渡します。入力例は次のとおりです。
"An item with this x Id already exists.
An item with this y id already exists.
An item with this barcode already exists.
"
つまり、文字列は文字通り、上の各行が\ nで区切られ、最後に\nが終わります。
function( msg )
{
alert( "\"" + msg + "\"" );
var aLines = msg.split( /\r?\n+/ );
for ( var i in aLines )
{
if ( !aLines[i] ) { alert( "Error!" ); continue; }
alert( i + ": \"" + aLines[i] + "\"" );
}
}
私はそれを行に分割し、行を繰り返します。インデックス3には、行がなく、最初の条件付きトリガーがあります。それは空の行ではありませんか?例: ""
次に、ループは実際にはもう1つの要素を4に移動し、関数の内容を表示します。
つまり、私は5つのアラートを受け取ります。
0: "An item with this x Id already exists."
1: "An item with this y id already exists."
2: "An item with this barcode already exists."
Error!
最後のものは最も奇妙です:
hasObject: "function(o) {
var l = this.length + 1;
... more lines ...
}
ここで何が起こっているのかわかりません。なぜもう1つの要素を繰り返すのですか?そして、なぜ最後の要素が関数なのですか?そして、オフセット3は空の文字列であってはなりませんか?つまり、「エラー」を警告するべきではありません。ここ。