How to get EnvDTE.CodeTypeRef from PropertyInfo.PropertyType (System.CodeDom.CodeTypeReference) - codedom

I am trying to get an EnvDTE.CodeTypeRef from a PropertyInfo.PropertyType.
I have tried the following
(EnvDTE.CodeTypeRef)(new CodeTypeReference(prop.PropertyType,CodeTypeReferenceOptions.GenericTypeParameter))
but get the following error message:
Running transformation: System.InvalidCastException: Unable to cast object of type 'System.CodeDom.CodeTypeReference' to type 'EnvDTE.CodeTypeRef'.
So, basically my question is how do I take a PropertyInfo.PropertyType and get an EnvDTE.CodeTypeRef from it?

Related

R bigrquery - how to catch error messages from executed SQL?

Say I have some SQL code that refreshes a table of data, and I would like to schedule an R script to schedule this code to run daily. Is there a way to capture any potential error messages the SQL code may throw and save that error message to an R variable instead of the error message being displayed in the R console log?
For an example, assume I have stored procedure sp_causing_error() in BigQuery that that takes data from a source table source_table and refreshes a target table table_to_refresh.
CREATE OR REPLACE PROCEDURE sp_causing_error()
BEGIN
CREATE OR REPLACE TABLE table_to_refresh AS (
Select non_existent_column, x, y, z
From source_table
);
END;
Assume the schema of the source_table has changed and column non_existent_column no longer exists. When attempting to call sp_causing_error() in RStudio via:
library(bigrquery)
query <- "CALL sp_causing_error()"
bq_project_query(my_project, query)
We get an error message printed to the console (which masks the actual error message we would encounter if running in BigQuery):
Error in UseMethod("as_bq_table") : no applicable method for 'as_bq_table' applied to an object of class "NULL"
If we were to run sp_causing_error() in BigQuery, it throws an error message stating:
Query error: Unrecognized name: non_existent_column at [sp_throw_error:3:8]
Are query error message displayed in BigQuery ever captured anywhere in bigrquery when executing SQL? My goal would be to have some sort of try/catch block in the R script that catches an error message that can then be written to an output file if the SQL code did not run successfully. Hoping there is a way we can capture the descriptive error message from BigQuery and assign it to an R variable for further processing.
UPDATE
R's tryCatch() function comes in handy here to catch the R error message:
query <- "CALL sp_causing_error()"
result <- tryCatch(
bq_project_query("research-01-217611", query),
error = function(err) {
return(err)
}
)
result now contains the error message from the R console:
<simpleError in UseMethod("as_bq_table"): no applicable method for 'as_bq_table' applied to an object of class "NULL">
However, this is still not descriptive of the actual error message we see if we execute the same SQL code in BigQuery, quoted above which references an unrecognized column name. Are we able to catch that error message instead of the more generic R error message?
UPDATE/ANSWER
Wrapping the stored procedure call within R using BigQuery's Begin...Exception...End syntax lets us get at the actual error message. Example code snippet:
query <- '
BEGIN
CALL sp_causing_error();
EXCEPTION WHEN ERROR THEN
Select 1 AS error_flag, ##error.message AS error_message, ##error.statement_text AS error_statement_text, ##error.formatted_stack_trace AS stack_trace
;
END;
'
query_result <- bq_table_download(bq_project_query(<project>, query))
error_flag <- query_result["error_flag"][[1]]
if (error_flag == 0) {
print("Job ran successfully")
} else {
print("Job failed")
# Access error message variables here and take additional action as desired
}
Warning: Note that this solution could cause an R error if the stored procedure completes successfully, as error_flag will not exist unless explicitly passed at the end of the stored procedure. This can be worked around by adding one line at the end of your stored procedure in BigQuery to set the flag appropriately so the bq_table_download() function will get a value upon the stored procedure running successfully:
BEGIN
-- BigQuery stored procedure code
-- ...
-- ...
Select 0 AS error_flag;
END;

MariaDB SphinxSE not accepting weights parameter

If I try this query:
select * FROM sphinx.products where `query` = "test";
it works. But if I try to give it weights it returns an error:
select * FROM sphinx.products where `query` = "test;sort=extended:#weight DESC;weights=3,1,1,1";
Fails with error:
Error in query (1430): There was a problem processing the query on the foreign data source.
Data source error: searchd error: invalid deprecated unordered_weight count 4 (expe
(Error reported by MariaDB gets truncated there, but I believe it says "expecting 0")
And:
select * FROM sphinx.products where `query` = "test;sort=extended:#weight DESC";
Fails with error:
Error in query (1430): There was a problem processing the query on the foreign data source.
Data source error: searchd error: index 'sku_products': sort-by attribute '#weight'
(Again, error returned by SphinxSearch gets truncated by MariaDB)
All the documentation I find about SphinxSE tells me to query the index this way, yet it does not work, but nobody in the Internet seem to have met this error since nobody is asking about this anywhere...
Am I doing something wrong?
Well, the option weights= didn't work, but it accepted fieldweights=sku,90,partnumber,30,barcode,20,name,10.
(I.e., fieldweights=<field1_name>,<field1_weight>,...)
Results came ordered by weight even without specifying sort=extended:#weight DESC, so I dodged both errors and got what I needed.
Hope this helps anyone in the same situation.

Anylogic - Error while drawing animation frame

I have a model and everything was working fine. i was just changing some values to try different scenarios and adding some graphs when I got the error msg:
Error while drawing animation frame. possibly created by dynamic properties of animation shapes
The only message I could get from the console window is:
Error during model creation:
java.base/java.lang.String cannot be cast to java.base/java.lang.Double
what could be the cause of this error?
Somewhere in your code, you might have attempted to convert a string into a double.
String Message = "1.20";
double res = (double)Message;
The above code is not allowed in Java
A condition like this might have occurred.
You are not allowed to put a string into a double variable:
double res = "1.2";

Error in levels(test$Variable1) = levels(train$Variable1) : attempt to set an attribute on NULL

levels(train$Variable1)
While running the above line, it executes well and shows me the result.
levels(test$Variable1) = levels(train$Variable1)
But trying to assign the output like the one shown above results in the below error. Looking for help to understand why it's happening and overcome it. Btw it's a factor variable.
Error in levels(test$Variable1) = levels(train$Variable1) : attempt to set an attribute on NULL

Errors when loading ci-merchant library

I'm trying to use http://ci-merchant.org/ for CodeIgniter. But when I load the merchant library, I get these errors:
A PHP Error was encountered
Severity: Warning
Message: stripos() expects parameter 1 to be string, array given
Filename: libraries/merchant.php
Line Number: 97
A PHP Error was encountered
Severity: Warning
Message: strtolower() expects parameter 1 to be string, array given
Filename: libraries/merchant.php
Line Number: 103
Here is my code:
$this->load->library('merchant');
$this->merchant->load('paypal_express');
Looking at the source of that file, the driver name needs to be passed as a string. So I highly doubt the two lines of code you put above is actually what's being called, it looks like you are passing an array as the driver name.
If you aren't sure where it's coming from, try adding some debug_print_backtrace() lines to the merchant.php file to figure out where the array is getting passed from.

Resources