Do thrown breakable items (like oil flasks) do damage when they hit?

Some items, specifically acid vials, alchemist’s fire, holy water, and oil flasks, allow you to throw them at enemies for various effects. To do this, you make a ranged attack, treating the object as an improvised weapon (which normally does damage equal to 1d4 + Dexterity modifier).

However, these objects have ‘on hit’ effects, such as dealing 2d6 damage in the case of the acid vial. Are these effects in addition to the ‘improvised weapon’ damage?

How can my rust code check for exceptions thrown by calls to java code?

I have rust code that invokes a java method:

let cls = je.find_class("com/purplefrog/batikExperiment/ToPixels")?;  let width = 400; let height = 400; let rgbs = je.new_byte_array(width*height*3)?; let rgbs2:JObject = JObject::from(rgbs);  let result = je.call_static_method(cls, "renderTo", "(II[B)V", &[     JValue::from(width),     JValue::from(height),     JValue::from(rgbs2), ])?; 

When I run it I get a lot of warnings like:

WARNING in native method: JNI call made without checking exceptions when required to from CallVoidMethod     at Method)     at sun.dc.DuctusRenderingEngine.createStrokedShape(     at java.awt.BasicStroke.createStrokedShape(     at org.apache.batik.gvt.StrokeShapePainter.getPaintedArea(     at org.apache.batik.gvt.StrokeShapePainter.getPaintedBounds2D(     at org.apache.batik.gvt.CompositeShapePainter.getPaintedBounds2D(     at org.apache.batik.gvt.ShapeNode.getPrimitiveBounds(     at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedPrimitiveBounds(     at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedBounds(     at org.apache.batik.gvt.CompositeGraphicsNode.getPrimitiveBounds(     at org.apache.batik.gvt.CompositeGraphicsNode.getTransformedPrimitiveBounds(     at org.apache.batik.gvt.AbstractGraphicsNode.getTransformedBounds(     at org.apache.batik.gvt.CompositeGraphicsNode.getPrimitiveBounds(     at org.apache.batik.gvt.AbstractGraphicsNode.getBounds(     at org.apache.batik.gvt.AbstractGraphicsNode.paint(     at com.purplefrog.batikExperiment.ToPixels.renderTo( 

How can I modify my code to check for exceptions so it will not print hundreds of these warnings?

Unexpected token error thrown by JSON parse

Need some help in figuring out this JSON error.

This is just a sample code provided in Mastercard payment gateway documentation. I am trying to test it with test data provided by the merchant. I ran the code through a validator and it doesn’t return any errors.

Here is the code I’m trying to execute.

<!DOCTYPE html> <html>     <head>         <script src=""                 data-error="errorCallback"                 data-cancel="cancelCallback">         </script>          <script type="text/javascript">             function errorCallback(error) {                   console.log(JSON.stringify(error));             }             function cancelCallback() {                   console.log('Payment cancelled');             }              Checkout.configure({                 "merchant" : "TEST",                 "order" : {                     "amount" : 1000,                     "currency" : "USD",                     "description" : "Ordered goods" ,                     "id" : 123                  },                 "interaction" : {                     "operation" : "AUTHORIZE",                      "merchant" : {                         "name" : "ABC Hotel" ,                         "address" : {                             "line1" : "some road" ,                             "line2" : "some city"                                   }                         }                 }             });          </script>     </head>     <body>         ...         <input type="button" value="Pay with Lightbox" onclick="Checkout.showLightbox();" />         <input type="button" value="Pay with Payment Page" onclick="Checkout.showPaymentPage();" />         ...     </body> </html>

enter image description here

CSOM : Exception of type ‘System.OutOfMemoryException’ was thrown

I am trying to get the details of users from User Profiles using CSOM. I have a list of users in Excel file(approx 20000).

I am reading the excel file and storing data in DataTable, i am iterating over the DataTable rows and trying to get details for each of the user using CSOM.

foreach (DataRow row in Inputtbl_ExcelFile.Rows)         {             GroupCollection grps1;             User user;             i++;             string loginName = "";             try             {                 loginName = row["UserID"].ToString();                 //loginName = @"dom434567";                 #region GetUserDetails                      user = clientContext.Web.SiteUsers.GetByLoginName(loginName);                     clientContext.Load(user, user1 => user1.LoginName, user1 => user1.Email, user1 => user1.Groups, user1 => user1.Id);                      grps1 = user.Groups;                     clientContext.Load(grps1, groups => groups.Include(group => group.Title, group => group.Users, group => group.Id));                     clientContext.ExecuteQuery();                  string groupName = string.Empty;                 if (grps1.Count == 0)                     groupName = "NT AUTHORITY\authenticated users";                 foreach (Group gr in grps1)                 {                     groupName = groupName + gr.Title + ";";                 }                 #endregion                  #region UserProf                 //// PeopleManager class provides the methods for operations related to people                 PeopleManager peopleManager = new PeopleManager(clientContext);                  PersonProperties personProperties = peopleManager.GetPropertiesFor(loginName);                  clientContext.Load(personProperties);                 clientContext.ExecuteQuery();                  string Sector = personProperties.UserProfileProperties["Sector"];                 #endregion                   Outputtbl.Rows.Add(i, user.Id, loginName.Replace("i:0#.w|", ""), user.Email, groupName, "Success", Sector);              }             catch (Exception ep)             {                 Outputtbl.Rows.Add(i, "", loginName.Replace("i:0#.w|", ""), "", "", "Failed ," + ep.Message, "");                  Console.WriteLine(ep.Message);             }             clientContext.Dispose();         } 

Now the issue is after some point of time, approx after it has iterated for 2000 items or sometimes 1500 or sometimes even after 3000 items, it throws an error at line :

user = clientContext.Web.SiteUsers.GetByLoginName(loginName); 

Exception of type ‘System.OutOfMemoryException’ was thrown.

I have gone through various article on internet and I understand that this is not related physical memory space but is given slot available at one time.

Can anybody please help me understand if there is any other issue in code or if i can improve code?

System.InvalidOperationException(An exception was thrown while attempting to evaluate a LINQ query parameter expression)

I don’t know what’s wrong with my LINQ query, everything looks fine but I got above error on the following code: if (!dbcontext.AndroidUser.Any(user => user.Equals(value.UserName))) Here’s my complete code for RegisterController.cs.

 using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using System.Threading.Tasks;  using APITesting.Models;  using APITesting.Utils;  using Microsoft.AspNetCore.Mvc;  using Newtonsoft.Json;   namespace APITesting.Controllers  {  [Route("api/[controller]")]  public class RegisterController : Controller  { NoNameRestaurantContext dbcontext = new NoNameRestaurantContext();  // POST api/<controller> [HttpPost] public string Post([FromBody]AndroidUser value) {     //First we need to check that user is existing in database.     if (!dbcontext.AndroidUser.Any(user => user.Equals                (value.UserName)))     {         AndroidUser user = new AndroidUser();         user.UserName = value.UserName;         user.Hash = Convert.ToBase64String(Common.GetRandomHash(16));         user.Password = Convert.ToBase64String(Common.HashPassword(             Encoding.ASCII.GetBytes(value.Password),             Convert.FromBase64String(user.Hash)));          //Save to Database          try         {             dbcontext.Add(user);             dbcontext.SaveChanges();             return JsonConvert.SerializeObject("Register Successfully");         }         catch (Exception ex)         {             return JsonConvert.SerializeObject(ex.Message);         }     }     else     {         return JsonConvert.SerializeObject("User is existing in Database");     }    }   }  } 

and for Common.cs class that I used to convert my password to hashPassword.

 using System;  using System.Collections.Generic;  using System.Linq;  using System.Security.Cryptography;  using System.Threading.Tasks;   namespace APITesting.Utils  {  public class Common  { /*  *   * FUNCTION TO CREATE RANDOM HASH STRING  *   */ public static byte[] GetRandomHash(int length) {     var random = new RNGCryptoServiceProvider();     byte[] hash = new byte[length];     random.GetNonZeroBytes(hash);     return hash; } /*  *   * FUNCTION TO CREATE PASSWORD WITH HASH  *   */ public static byte[] HashPassword(byte[] password, byte[] hash) {     HashAlgorithm algorithm = new SHA256Managed();     byte[] plainTextWithHashByte = new byte[password.Length + hash.Length];     for (int i = 0; i < password.Length; i++)     {         plainTextWithHashByte[i] = password[i];     }     for (int i = 0; i < hash.Length; i++)     {         plainTextWithHashByte[password.Length + i] = hash[i];     }     return algorithm.ComputeHash(plainTextWithHashByte);   }  } } 

I am following this tutorial:

Does the special thrown attack of a Hammer of Thunderbolts deal damage?

The Hammer of Thunderbolts has a special thrown property:

The hammer also has 5 charges. While attuned to it, you can expend 1 charge and make a ranged weapon attack with the hammer, hurling it as if it had the thrown property with a normal range of 20 feet and a long range of 60 feet. If the attack hits, the hammer unleashes a thunderclap audible out to 300 feet. The target and every creature within 30 feet of it must succeed on a DC 17 Constitution saving throw or be stunned until the end of your next turn. The hammer regains 1d4 + 1 expended charges daily at dawn.

I suspect it is probably the case, but just to be sure:
Does the special thrown attack of a Hammer of Thunderbolts deal damage, in addition to its stated effect? (2d6+1 + Strength modifier + other bonuses if any)

Error Thrown When Toggling ‘Quick Edit’ on a List or Library

For some reason users are getting the following popup/error when toggling ‘Quick Edit’ on a list or library.

This site says…

Assertion Failed: Edit manager is still in Editing state, but focus is on the grid’s input element!

Break into debugger?

Popup Error

No errors are showing in Chrome’s developer tools console. However it is showing the following messages… (I’m not sure if they are related.)

[Violation] Added synchronous DOM mutation listener to a 'DOMSubtreeModified' event. Consider using MutationObserver to make the page more responsive. 
[Violation] 'click' handler took 34811ms 
[Violation] Forced reflow while executing JavaScript took 35ms [Violation] Forced reflow while executing JavaScript took 38ms 

Does the 2019 UA artificer’s Arcane Weapon spell apply to thrown weapons?

I was making an artificer (from the May 2019 UA) who has a dagger with the Returning Weapon infusion. I planned on using the arcane weapon spell with it, but I am unsure if it works.

Arcane weapon states:

You channel arcane energy into one simple or martial weapon you’re holding, and choose one damage type: acid, cold, fire, lightning, poison, or thunder. Until the spell ends, you deal an extra 1d6 damage of the chosen type to any target you hit with the weapon.

This spell seems to work with ranged weapons such as bows and melee weapons, but would it work with a thrown weapon such as a dart or javelin?

Should exceptions be only thrown if I intend to crash the program? [duplicate]

This question already has an answer here:

  • Do exceptions basically exist to prevent a system from crashing? 7 answers

…I wanted to find the source before writing this Q, sadly I couldn’t.

My mental model was that exceptions were thought as an alternative to returning error codes from a function, which is the C way to signalize failure. Returning error codes and managing them is error-prone, cumbersome and tedious; which is why a more right-handed mechanism was thought.

Problem is, then I started reading and hearing opinions that abusing exceptions is bad. Well of course – if I want to see if an array contains element X then it would probably not be a good idea to assume it does and then throw and almost immediatelly catch an exception if it doesn’t.

But these opinions were more strict than that. An example of an improper use of exceptions was if, for example, we have a web app and a user requests something that is not there / sends invalid data / any other condition arises that requires displaying an error page to the user. In this case, I was told, it would be a bad practice to throw an exception deep down in the server code, catch it before the request stops being processed and then display an error page.

If I understand this mentality correctly (which doesn’t have to be the case), the justification was that, since throwing the exception is not intended to crash an app (the situation is recoverable), then the situation is “sensible business-wise”; while exceptions should be reserved for situations “insensible business-wise”, which I suppose means “unrecoverable”? But this seems to imply that if the app can continue and is not supposed to crash, I should not throw exceptions; I should only throw if the app cannot continue and must crash.

Is this commonly agreed upon? If so, then why?

I have feeling this is supposed to apply to almost all programming languages (but, notably, not Python.)

I must admit in my anti-pattern ridden game I do otherwise. For example, when the user sends a JSON with a team, I obviously must validate this data. I seem to be doing precisely what is condemned above: I pass the JSON data to the pieces of code that are responsible for validating it and, if it’s valid, constructing an instantiation of the Team class. If the data is invalid, an exception is thrown. I thought this would be convenient for me, especially since this seems to mix well with C# facilities I use to construct the team: for example, to instantiate a Monster subclass from a monster name present in the JSON, I use Activator.CreateInstance which naturally throws if the monster name present in the JSON doesn’t match any subclass of Monster.

But, well, others are more experienced than me, I marked this with a TODO that I should refactor this to if(isValid(teamJson)) team = new Team(teamJson) even though I don’t understand why and even thought I don’t like this idea because isValid() would have to share a lot of code with the Team() constructor.

Yesterday, however, I read something surprising: Throwing exceptions on assertion failures is, generally, a bad idea, because assertion failure should crash the program while an exception can be caught*. This seems to go against the mentality I presented above, which would assert that exceptions should be thrown precisely when the program must crash.

Could you clear my confusion? When should exceptions be thrown? In particular, should exceptions be thrown then and only then when the program should crash?

*(Yes, this applies to C++ while remarks about my game were about C#; but again – I don’t want to discuss language facilities of this or other language, but when exceptions should be thrown in general, which – again – is AFAIK language-agnostic, although with few exceptions like Python.)

Looping into all websites, PowerShell error: Exception has been thrown by the target of an invocation

I have some powershell script which is looping into all websites in a webapplication. I have full control permissions in the policy in Central Admin. In this powershell loop I got this error at some sites:

PowerShell and Sharepoint: Exception has been thrown by the target of an invocation.

I think this error occurred because I don’t have permissions at some websites. But I would like to skip sites which throw these errors. How can I do that? This is my script:

if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $  null) {      Add-PSSnapin "Microsoft.SharePoint.PowerShell"  }   $  webApp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup("")   foreach ($  site in $  webApp.Sites)  {       foreach($  webSite in $  site.AllWebs)      {        # some logic      } }