code: function (error) {
                  // If the request was already cancelled, no need to emit anything.
                  if (cancelled) {
                      return;
                  }
                  cleanup();
                  // Wrap the error in a HttpErrorResponse.
                  observer.error(new HttpErrorResponse({
                      error: error,
                      status: 0,
                      statusText: 'JSONP Error', url: url,
                  }));
              }
docs: onError() is the error callback, which runs if the script returned generates a Javascript error. It emits the error via the Observable error channel as a HttpErrorResponse.