Twitterizer api search function throws exception - twitter

when i call for search function like:
TwitterResponse<TwitterSearchResultCollection> result = TwitterSearch.Search("#hastag");
it throws exception like: Error converting value 0,148 to type 'Twitterizer.TwitterSearchResultCollection'. JsonParsingException.
im using the latest version of api. is there anything that i can do to solve it?

Related

Checking Promise or Callback type of an API

How can we test the type of an API?
It is not practical to check Chrome version for each API.
For example chrome.contextMenus.removeAll() is still callback (but may change in future).
chrome.contextMenus.removeAll(() => chrome.contextMenus.create(item));
// ----- vs -----
chrome.contextMenus.removeAll()
.then (() => chrome.contextMenus.create(item));
Using then() on an API that hasn't been converted to a Promise will result in error.
TypeError: Cannot read properties of undefined (reading 'then')
Using a callback on an API that has been converted to a Promise will also result in error.
Uncaught SyntaxError: Unexpected token ')'
Previously: List of Promise API in manifest v3
I consulted with one of our engineers. The short answer is that you don't need to. If you pass a callback, no promise will be returned, and you'll get a promise if you don't pass a callback.
This should be true of all methods that take callbacks. If you know of one or find one where this isn't true, please let me know in a comment and I'll look into it.
The best solution that I have come up with so far has been the following:
// result for a callback type API
typeof chrome.contextMenus.removeAll()?.then() // 'undefined'
// result for a Promise type API
typeof chrome.storage.local.get()?.then() // 'object'
Therfore, the type can be checked like the following:
typeof browser.contextMenus.removeAll()?.then() === 'undefined' ?
chrome.contextMenus.removeAll(() => someFuntion()) :
chrome.contextMenus.removeAll().then(() => someFuntion());

How do I test dart NoSuchMethodError

How do i test for a class that some method doesn't exists NoSuchMethodError Exists?
something like the below example.
expect(1.leftShift(12), NoSuchMethodError);
You can test this like you would any other error. You can pass in a function that throws the error into expect and check that it throws the right error:
const dynamic x = 'hello';
expect(() => x.notAMethod(), throwsA(isA<NoSuchMethodError>()));
Note that you will need to make your receiver (the object you are calling the method on) to be dynamic to suppress the static error that would otherwise catch this error.

Cannot convert value to bool : InvalidArgumentException

I am using cakephp 3.3 for my vod application and i want to insert data using following query:
$query=$notifications->query()->insert(['message' ,'status','user_id' ,'video_id' ,'notify_to' ,'notification_type'])
->values([
'message'=>'Congratulations! your video '.$video_name.' has been approved to be uploaded on MM2View by admin.',
'status'=>$status,
'user_id'=>$user_id[0]['users_id'],
'video_id'=>$id,
'notify_to'=>1,
'notification_type'=>3
])
->execute();
But i am getting
Cannot convert value to bool : InvalidArgumentException Error message. I have done some google related to this problem but did not find any correct solution.
Invalid argument exceptions are caused because of type mismatch in operations you written in the code.
Check your model class for the type you given and compare it with the code

Convert a CanvasRenderingContext variable for a javascript API

I have a javascript API that takes a canvas context as an argument
The following
var context2dJs = new js.JsObject.fromBrowserObject(canvas.getContext('2d'));
throws Exception: Uncaught Error: object must be an Node, ArrayBuffer, Blob, ImageData, or IDBKeyRange
but the following works
var context2dJs = new js.JsObject.fromBrowserObject(canvas).callMethod('getContext', ['2d']);
However, designing a wrapper around this API, I'd like the dart API to be similar and have a CanvasRenderingContext parameter. How can I convert such dart parameter to its javascript equivalent?

Using dart:web_audio

I have some confusion debugging some simple app that uses the Web Audio API.
In the developer console I can do something like this:
var ctx = new webkitAudioContext(),
osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
Trying to get this to work with Dart yields the following errors when I try it like this:
AudioContext ctx = new AudioContext();
OscillatorNode osc = ctx.createOscillator();
osc.connect(ctx.destination);
osc.start(0);
//Dart2JS: Uncaught TypeError: Object #<OscillatorNode> has no method 'connect$1'
//DartVM: Class 'OscillatorNode' has no instance method 'connect' with matching
arguments. NoSuchMethodError: incorrect number of arguments passed to method
named connect' Receiver: Instance of 'OscillatorNode'
Stepping through I found that there are two kinds of implementations to the connect method. So I tried to add an extra second param and since I can not really wrap my head around why it needs an int named "output", thinking maybe it is for volume I decided on the value 1 but that yields:
//Dart2JS: Uncaught Error: IndexSizeError: DOM Exception 1 flexsynth.html_bootstrap.dart.js:8698 $.main flexsynth.html_bootstrap.dart.js:8698 $$._IsolateContext.eval$1flexsynth.html_bootstrap.dart.js:565 $.startRootIsolate flexsynth.html_bootstrap.dart.js:7181 (anonymous function)
//DartVM: "Dart_IntegerToInt64 expects argument 'integer' to be non-null."
Here is where I can't figure out what to do, I think the argument is not null, it is 1.
Googling the errors only leads me to the actual Dart source code.
Is there any place that explains how to work with the dart:web_audio? What am I doing wrong?
This is because the underlying implementation seems to require the parameter input, despite it being an optional parameter. This code will work:
AudioContext ctx = new AudioContext();
OscillatorNode osc = ctx.createOscillator();
osc.connect(ctx.destination, 0, 0);
osc.start(0);
This is a known bug, you can star it here: https://code.google.com/p/dart/issues/detail?id=6728

Resources