I have integrated sentry on one of my NextJS application and using captureException in the catch block to capture exceptions on the platform. Still it is not logging out all the nested error object fields rather it is logging only the error message. Tried other various functions as well but none of them is fulfilling my use case.
Tried all workarounds but got no help. Following is the code, I have used
catch (error) {
console.log("log message", error);
console.error("error message", error);
console.log("log message", JSON.stringify(error));
console.error("error message", JSON.stringify(error));
Sentry.addBreadcrumb({
message: 'Breadcrumb message 1',
});
Sentry.captureMessage('Message 1');
Sentry.captureException('Error 1');
Sentry.captureException(error);
Sentry.captureException(new Error(error));
Sentry.captureEvent({
message: 'Manual'
});
Sentry.captureEvent(error);
Sentry.captureEvent(new Error(error));
}
Checked sentry docs and forums but got no help from there as well. If there is any other solution also, please let me know
You can use ExtraErrorData as following in Sentry.init method for this
import { ExtraErrorData } from "#sentry/integrations";
integrations: [
new ExtraErrorData({ depth: 10 })
]
Related
I'm upgrading a project to Nuxt3 and I'm using the new $fetch to hit my API, all it's OK but I can't manage the handle the 422 error from the API.
The API I've created would return something like this for the 422 code
{ message: "The email has already been taken.", errors: { email: ["The email has already been taken."]}}
Then in Nuxt I'm using this:
$fetch(`${runtimeConfig.public.BASE_API_BROWSER_URL}/XXX/`, {
method: 'POST',
body: {
...data
}
})
.then((resp) => {
message.value.push(resp.message)
isSubmitting.value = false
})
.catch((error) => {
errors.value.push(error.message)
isSubmitting.value = false
})
But what I have back is just FetchError: 422 Unprocessable Content instead of the error inside the API response, any idea on how to able to use error.message again?
Should be typically accessible via error.response.message.
For better visibility of the error object structure, use console.dir to explore its contents in the browser console: console.dir(error)
Unlike console.log(var1, var2, var3), console.dir only handles one attribute.
Important to remember this else you will be misled to thinking variables are empty.
Is it possible to manually track exceptions using Firebase GA4 Analytics?
I have been checking few documents that refers to two different events:
app_exception
exception
So... what should I do? Are both ways correct?
analytics.logEvent("exception", {
description: error.message ?? "Unexpected error.",
fatal: false,
});
VS
analytics.logEvent("app_exception", {
description: error.message ?? "Unexpected error.",
fatal: false,
});
Please find the attached screenshot for exact error. I'm getting this error when I'm trying to set the data to firestore. Following is the code
import firebase from 'react-native-firebase';
export function initializeFirestore() {
firebase
.firestore()
.collection('communities')
.doc('communityname')
.collection('members')
.doc('memberid')
.set({ field1: 'value1' })
.then(function(docRef) {})
.catch(function(error) {
console.error('Error updating userChannel : ', error);
});
}
screenshot
I'm not sure if you got your answer but, the only workaround I've been seeing is to downgrade firebase-firestore to 17.1.5
in app level Build.gradle file add
implementation "com.google.firebase:firebase-firestore:17.1.5"
I got the answer from here
I am currently developing a mobile app with ionic. On this application there is a local sqlite database.
I am looking to be able to execute queries from files for possible updates of the database.
For example, when you first install the application, the tables are created if they do not exist. If changes are made to these tables after installing the application, the changes are not taken into account.
I would like to create files which can be executed one by one according to PRAGMA user_version.
Something like :
// Get pragma user version, if it's undefined, it's set to 1.
// If user_version < 1, we execute the sql file, then we update the user_version
// to 1.
db.executeSql(`PRAGMA user_version;`, []).then((res)=> {
if(res.rows.item(0).user_version < 1) {
db.sqlBatch(`app/sqlFiles/1.sql`, []).then((res)=>{
console.log(res);
}, (err) => {
console.log("Error : " + JSON.stringify(err));
});
db.executeSql(`PRAGMA user_version = 1;`, []).then((res)=>{
console.log(res);
}, (err) => {
console.log("Error : " + JSON.stringify(err));
});
}
}, (err) => {
console.log("Error : " + JSON.stringify(err));
});
I thought about using a file reader but the file is not found during the execution of the function.
this.fileOpener.open('assets/SQLFile/1.sql', 'text/plain')
.then((file) => {
var reader = new FileReader();
reader.onloadend = function(evt) {
console.log("read success");
console.log(evt.target);
};
db.sqlBatch(reader.readAsText(file)).then((res)=>{
console.log(res);
}, (err) => {
console.log("Error : " + JSON.stringify(err));
});
console.log('File is opened');
})
.catch(e => console.log('Error opening file', e));
Will anyone have an idea for doing this kind of thing? (I am looking for a solution that respects good programming practices).
Please note that I am a beginner with ionic and sqlite
Thank you in advance !
But you're getting an error or what? Since the post seems to be valid but the implementation seems to be a little off.
After reading the file, storing the content into a variable, you should execute that "sql query" as usually.
Nevertheless it's not a secure way of do that.
When something in your app change due to an update or upgrade, wouldn't be easier and safer to specify that into the code instead of a single file containing all the database info and scheme?
Edited:
If you want to add custom files to deployment, check this out https://ionicframework.com/docs/developer-resources/app-scripts/
When trying to invoke the Stackdriver Error Reporting API (via the API explorer or via the Client-Side JavaScript library), I receive the following error:
Request:
{ "message" : "test" }
Response:
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT"
}
}
The Stackdriver Error Reporting API is enabled and I have Owner rights to the App Engine project.
Is the API simply not functional? If I'm doing something wrong, can someone try to help?
The documentation for reporting events says that a ServiceContext is required.
If you're only sending a message (not a stacktrace / exception) you'll need to include a context with a reportLocation as well. This is noted in the documentation of the message field, but it's not obvious.
The following works from the API explorer:
{
"context": {
"reportLocation": {
"functionName": "My Function"
}
},
"message": "error message",
"serviceContext": {
"service": "My Microservice",
}
}
You might be interested in the docs on How Error are Grouped too.
FWIW, I work on this product and I think the error message is too generic. The problem is (?) that the serving stack scrubs the message unless they're annotated as being for public consumption. I'll chase that down.