Office.context.mailbox.item.body.getAsync returns error 9020 An internal error has occured - outlook-web-addins

I am using a tutorial that gets the email email properties using Outlook Add-in and now I am trying to get the email body. All the research I am getting is using mostly this statement to get it.
function getEmailBody() {
Office.context.mailbox.item.body.getAsync(Office.CoercionType.Text, function callback(asyncResult) {
return asyncResult.value;
});
But when I run it, it returns empty and when I put a debugger on it, the asyncResult has these values:
value: null
status: failed
error: OSF.DDA.Error
name: GenericResponseError
message: An internal error has occurred.
code: 9020
Does anyone knows what is causing this error? I am using outlook.office.com in Google Chrome to access the emails.

Related

How to display an error message to a user?

I created a like button in my solid-js app that does not allow someone to like a post they authored. For this, I wrote the following code:
const isPostAuthor = postAuthor.authorId === currentUser.id;
if (isPostAuthor) {
return next({
status: 401,
message: "You can`t add a like on your own post"
});
In order to check if the user who likes is the author of the post and to return an error message with status 401 to the user if it is the case. It works fine only that the error message is not displayed to the user instead, it instead displays a red cross to the user; However, this message is displayed on the command line. I thought it was a status error, so I changed the error status 401 to status 400 and then 404 but it still didn't show the error message to the user . So I tried out of curiosity the status 200 used for successful operations, it did return a message to the user but in green color yet the operation failed, I don't know why it works with the success code 200 but not with error codes . Could someone help me?
If my hypothesis is correct based on your explanation, wherever you are receiving this response, you need to add two sections to catch this response, one is success response and the other is error response, because as you said for 200 status code, it is showing the message and indicates the success response, that is the reason you could able to see the message for the user.
You can try adding error section in your code wherever you are receiving this response and see if you could able to catch this user message
hope my hypothesis helps :)

Weird error 'UnhandledPromiseRejectionWarning: ReferenceError: message is not defined'

I'm trying to make a discord bot and it works fine but there's one thing that doesn't work. For some reason, it gives me this error when I try to do something with the bot. UnhandledPromiseRejectionWarning: ReferenceError: message is not defined I have no idea why. Heres the code that has the error: const collector = reactionMessage.createReactionCollector((reaction, user) => message.guild.members.cache.find((member) => member.id === user.id).hasPermission("MANAGE_NICKNAMES"), { dispose: true }
Heres's some context of what the bot is if that helps: It's a ticket bot, where members can report problems to mods in a private channel. It creates a channel, and sends a message saying "staff will be with you shortly" and puts reactions so that you can close the ticket. When I try to close the ticket, it gives the error. The error happens around user.id).haspermission("MANAGE_NICKNAMES") That code is supposed to make people without the MANAGE_NICKNAMES permission unable to use the reactions, and theres no place in the code that i'm supposed to put 'message' so why is this happening?
Try replacing places message to reaction.message and if it doesn't work try using partials

How to add custom paramater in error object lb4?

I am using strongloop 4 (lb4). I am facing one issue that in error object I need to one more custom parameter in the error object.
I want it on the global level. On every error, I want to add that custom parameter in every error message.
In loopback4 global error handling is done by src/sequence.ts.
Suppose the error message object is.
{
"error": {
"statusCode": 400,
"name": "xyz",
"message": "firstName is required"
}
}
I want error object output like.
{
"error": {
"customParam" : "customParam",
"statusCode": 400,
"name": "xyz",
"message": "firstName is required"
}
}
Cross-posting the answer I gave on GitHub in https://github.com/strongloop/loopback-next/issues/1867#issuecomment-434247807
Building HTTP error responses is a tricky business. It's easy to get it wrong and open your application to attacks.
In LoopBack (both 3.x and 4.x), we use our strong-error-handler middleware to take care of this. See Handling Errors in our docs.
Here are the important security constraints to keep in mind:
In production mode, strong-error-handler omits details from error responses to prevent leaking sensitive information:
For 5xx errors, the output contains only the status code and the status name from the HTTP specification.
For 4xx errors, the output contains the full error message (error.message) and the contents of the details property (error.details) that ValidationError typically uses to provide machine-readable details about validation problems. It also includes error.code to allow a machine-readable error code to be passed through which could be used, for example, for translation.
In debug mode, strong-error-handler returns full error stack traces and internal details of any error objects to the client in the HTTP responses.
Now that I have warned you, LoopBack 4 makes it very easy to format the error messages your way. Just provide a custom implementation of the Sequence action reject. See Customizing Sequence Actions in our docs, it explain how to create a custom send action. The solution for reject is pretty much the same, you just need a different signature for the action function.
export class CustomRejectProvider implements Provider<Reject> {
// ...
action({request, response}: HandlerContext, error: Error) {
// handle the error and send back the error response
// "response" is an Express Response object
}
}
Caveat: some errors thrown by LB4 have only code set, these errors need a bit of pre-processing to decide what HTTP status code they should trigger. (For example, the error code ENTITY_NOT_FOUND should be mapped to the status code 404). The built-in reject action does not yet expose this pre-processing for consumption by custom reject actions. It's an oversight on our side, l created a new issue https://github.com/strongloop/loopback-next/issues/1942 to keep track of that.
I tried adding error object into new object.
let error = new Error();
error.name = 'Invalid_OTP_AttemptsError';
error.status = 422;
error.message = 'You’ve exceeded the maximum number of One-Time Password (OTP) attempts';
let data={...error};
data.retryCount=foundMb.retryCount
data.resendCount=foundMb.resendCount
return callback(null,data);

How do I init XOD in WebViewer? "DisplayModes" is undefined

I'm trying to load a XOD document into a PDFTron WebViewer. As far as I can read in the documentation and samples, this should be a simple "plug and play"-operation - it should simply work when you point at a file. Ideally, in my example, the document should be fetched from a service, as so:
fetch('/myservice/GetXOD')
.then(function(data) {
$(function() {
var viewerElement = document.getElementById("viewer");
var myWebViewer = new PDFTron.WebViewer({
initialDoc: data.body
}, viewerElement);
});
});
Unfortunately I get the following error:
Uncaught TypeError: Cannot read property 'DisplayModes' of undefined
The reason I'm doing it in a fetch, is because I'm rendering a Handlebars template, and pass the data to instantiate in a callback. However, I've isolated the code into an otherwise "empty" HTML-document, and in the simplified example below, I'm simply pointing at the XOD provided by PDFTron on page load (no fetch this time).
$(function() {
var viewerElement = document.getElementById("viewer");
var myWebViewer = new PDFTron.WebViewer({
initialDoc: 'GettingStarted.xod' // Using the XOD provided by PDFTron
}, viewerElement);
});
This unfortunately returns a different error (HTTP status 416).
Uncaught Error: Error loading document: Error retrieving file: /doc/WebViewer_Developer_Guide.xod?_=-22,. Received return status 416.
The same error appears when I run the samples from PDFTron on localhost.
I'm at a complete loss of how I should debug this further - all the samples assume everything is working out of the box.
I should note that I can actually get PDFs working just fine on localhost, but not on the server. XODs are problematic both on the server and on localhost.
I'm sorry to hear you are having troubles running our samples.
Your error message says 416 which means "Requested range not satisfiable". Perhaps your development servers do not support byte range requests (https://en.wikipedia.org/wiki/Byte_serving).
Could you try passing an option streaming: true? When streaming is true you're just requesting the entire file up front which shouldn't be a problem for any servers but it is a problem for WebViewer if the file is large because it will need to be completely downloaded and parsed at the start which is slow.

A weird Error object is being logged to console

I am trying to post comments through the youtube API, but they are returning an error upon trying.
When I log the error object I get
{ [Error: Bad Request] code: 400 }
The first part of which looks weird (key-value inside array?)
I tried to log the keys of the object and it only returns code
Supposely the API return a much more detailed message, but it's like it's 'hidden' inside the [Error: Bad Request], which I dont know how to access
That's just how Node formats errors.
Try it yourself in a node console:
var e = new Error("Test");
e.code = 500
console.log(e); // Outputs: { [Error: Test] code: 500 }
As far as your issue with the YouTube API, I suggest creating a different question on StackOverflow about your issues, providing more information around how you are calling the API.

Resources