How do I error handle a datasource Access Denied error in PowerQuery? - powerquery

In PowerQuery, either Excel or PowerBI, I want to trap the error that occurs when I don't have access to a data source.
Problem is that whatever I try, seems to be saying to me that "we can't authenticate you to tell you whether the data source you're trying to access exists"
let
Source = (url as any) =>
let
test = try OData.Feed(url, null, [Implementation="2.0"]),
testResult = if test[HasError] then "No list" else "list is accessible"
in
testResult
in
Source
If I try a different Source approach
test = SharePoint.Tables("https://....sharepoint.com/...)
I still have the same issue.
It's not an http error - it's an authentication issue.

Related

GoLang web service - How to translate errors declared in package

I'm implementing server using GIN Framework.
The Gin framework has a handler for each route.
Each function handler has it's own controller that returns some result (basically error)
package controller
var (
ErrTooManyAttempts = errors.New("too many attempts")
ErrNoPermission = errors.New("no permission")
ErrNotAvailable = errors.New("not available")
)
This errors are created for developers and logging, so we need to beautify and translate these before sending them to the client.
To be able to get translation we should know the key of the message.
But the problem is I need to bind these errors in some map[error]string (key) to get translation key by error.
It's quite complex because I have to bind all the errors with the corresponding keys.
To improve it, I'd like to use reflection:
Get all variables in the package
Walk through and find Err prefix
Generate translation key based on package name and error name, ex: controller-ErrTooManyAttempts
Merge translation file, so it should look like this:
`
{
"controller-ErrTooManyAttempts": "Too many attempts. Please try again later",
"controller-ErrNoPermission": "Permission to perform this action is denied",
"controller-ErrNotAvailable": "Service not available. Please try again later"
}
`
What is the correct way to translate errors from the package? Is it possible to provide me with some example?

Change error system message in oracle apex

I have a form page and all field is required when press save the below message appear
How i can change this message to custom message "please fill all required fields " , and how i can clear error when enter value (when value change to not null).
I can't see images at the moment.
However, one option might be to create your own validation which returns error text. Something like
if :P1_NAME is null then
return ('Name must be entered');
end if;
Messages are automatically cleared once you submit the page and there are no errors left.
I am not sure if you can change system messages but you can add custom error messages with javascript if a change happens in any item.
Add a change event to the item that runs javascript and use the following code:
var item = apex.item('P1_ITEM').getValue();
if(item == null) {
//First clear the errors
apex.message.clearErrors();
// Now show new errors
apex.message.showErrors([
{
type: "error",
location: [ "page", "inline" ],
pageItem: "P1_ITEM",
message: "Name is required!",
unsafe: false
},
{
type: "error",
location: "page",
message: "Page error has occurred!",
unsafe: false
}
]);
}
However, this will not stop the user from submitting, it only allows you to better display the messages, so you must add the corresponding validations after submit.
If you want to remove the system error message from the required items, you can disable the option of Value Required on item and add a custom validation as they told you in the other response.
If you want to explore all the apex.message options better, I recommend this documentation:
https://docs.oracle.com/database/apex-5.1/AEAPI/apex-message-namespace.htm#AEAPI-GUID-D15040D1-6B1A-4267-8DF7-B645ED1FDA46
More documentation for apex.item:
https://docs.oracle.com/cd/E71588_01/AEAPI/apex-item.htm#AEAPI29448
There are some ways for how to do such things.
Firstly you have the custom Validations you can make, these are awesome and you should really try to use them if possible.
Then there is also the Error message on the saving procedure, but this just throws a custom message on procedure fail so I never use it.
What you appear to be seeing there is that you got an error message and didnt change the fields associated with the error.
If the save procedure is custom, you can also put in an EXCEPTION block before the END, and catch errors there and throw out a custom error with a custom error message.
Another thing I really like is to actually rename some common errors so I dont have to catch them all individually. Say clients may often times try to save identical data, thus breaking the PK. Oracle will throw an error, but the message is good for the developer, but less understandable for the client whom I always assume is a 3 year old kid who can barely read and will cry over everything. So I make an error handling function, add it to apex, and so when the error occurs, it throws a nice message informing the client that they have tried to add some data that already exists.
So, an error handling function associated with APEX, to rename some normal errors.
Good luck

Find file that generated error CSRF TOKEN

I set up the handler file for whenever there is an error on the server, I receive an email with the details.
So today I received an email with the following error:
array (3) {["message"] => string (0) "" ["file"] => string (104)
"/var/www/infochat/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php"
["line"] => int (71)}
I know what this error is, but the problem is that I do not know what caused it, what file or code it was responsible for.
I did not find anything in the logs (I may have seen the wrong log). Is there somewhere I can check to find out?
There is absolutely no way to tell which file sent it if that's the only thing youre getting from the error stack on your email.
I'd get a cup of coffee, fire up the IDE and start doing a "Find all" for "

Error when creating ACL in Cloud Code: invalid permission type

TL;DR
Setting an ACL with a role permission fails sometimes because the role's name is interpreted as the permission type.
The setup
In a Cloud Code function, I create an ACL object and use setRoleReadAccess to grant read access to a role:
const roleName = 'foo'; // this string is actualy calculated, but always non-nil and non-empty
const acl = new Parse.ACL();
acl.setRoleReadAccess(roleName, true);
Then I set that ACL to a new (unsaved) object:
const myObject = new MyObject()
myObject.setACL(acl);
The error
The setACL call causes an exception with the error message Tried to create an ACL with an invalid permission type. which seems strange since I didn't provide a custom permission type.
What I tried so far
I tried to set the role as a Role object instead of a string, but that didn't make a difference.
After some debugging I found that the error originates in ParseACL.js (line 85), where the permission string must either match read or write; however, in my case that string matches the role name (in the example above "foo").
I have similar ACL/role code in other parts of my app, so I'm sure this should work. Now I'm looking for hints -- what might cause the weird behavior that the role name is interpreted as permission type -- and tips on how to further debug this issue.
(Using parse-server version 2.3.3 and node.js 6.4.0; I'm currently locked to that Parse version.)
The issue was caused by having global.Parse = require('parse/node') in a global Mocha test setup file; when running all integration tests (> 300 tests, taking about 4 minutes) this caused some weird effects like the mentioned Tried to create an ACL with an invalid permission type, but also You cannot use [object Object] as a query parameter; both errors only occurred when the runtime was under heavy load and running all tests -- just running a single test never produced any errors.
Details in this Github issue.

Error: "include is invalid for non-ParseObjects" (using parse-osx-library-1.7.5)

I have a Meal object that stores pointers to n created objects "FoodInfo" using the key "MealItems".
When I query for the meal I take advantage of the [query includeKey:#"MealItems"] to fetch the items pointed to while fetching the "Meal".
This works swimmingly if the objects are created while online (ie. all are stored in the cloud db).
However, since I cannot assume access to the cloud at all time for this app I am now trying to enable the local datastore so I've changed my queries to use:
[query fromLocalDatastore];
and I've changed all of my objects' save methods to pinInBackgroundWithBlock followed by (assuming success of local save) saveInBackgroundWithBlock followed by (assuming failure) saveEventually.
To test this, I:
turned off wifi
ran the code to create a meal and then add newly created foods to it. This works with no error codes.
ran a report that then queries for the meal just created. This fails with the following:
Error: Error Domain=Parse Code=121
"include is invalid for non-ParseObjects" UserInfo=0x60800007f400 {
error=include is invalid for non-ParseObjects,
NSLocalizedDescription=include is invalid for non-ParseObjects,
code=121
} {
NSLocalizedDescription = "include is invalid for non-ParseObjects";
code = 121;
error = "include is invalid for non-ParseObjects";
}
Is this scenario not supported?
When I re-enable wifi, the meal is successfully added to the online db, but the query failure still happens when I run the query with the includeKey locally.
Am I missing something here? I'm quite surprised to see this failing. It seems like a really basic feature that should work whether local or cloud based.
Parse objects are not created until you save them. Try using saveEventually first before using pinInBackgroundWithBlock.

Resources