Error Handling with Angular 8 – Tips and Best Practices

Handling errors properly is essential in building a robust application in Angular. Error handlers provide an opportunity to present friendly information to the user and collect important data for development. In today’s age of advanced front-end websites, it’s more important than ever to have an effective client-side solution for error handling.

An application that does not handle errors gracefully leaves its users confused and frustrated when the app suddenly breaks without explanation. Handling these errors correctly across an application greatly improves user experience. Collected data from the error handling can inform the development team about important issues that slipped past testing. This is why monitoring tools like Rollbar are so important.

In this article, we will compare several solutions for error handling in Angular apps. First, we will describe the traditional approaches using ErrorHandler and HttpClient. Then, we will show you a better solution using HttpInterceptor. We’ll also show you how to use this interceptor to monitor and track errors centrally in Rollbar.

 

Source: Error Handling with Angular 8 – Tips and Best Practices

Oracle SQL-Developer: Show timestamp in date columns

You can decide how SQL-Developer display date and timestamp columns.

  1. Go to the “Tools” menu and open “Preferences…”
  2. In the tree on the left open the “Database” branch and select “NLS”
  3. Now change the entries “Date Format”, “Timestamp Format” and “Timestamp TZ Format” as you wish!

ISO formated output with date and time

  • Date Format: YYYY-MM-DD HH24:MI:SS
  • Timestamp Format: YYYY-MM-DD HH24:MI:SSXFF
  • Timestamp TZ Format: YYYY-MM-DD HH24:MI:SSXFF TZR

Source: SQL-Developer: How to change the date format of the result grid – “Why does my date column have no time?” | Oracle Deli

RepoZ: A git repository hub for Windows and macOS with Windows Explorer- & CLI-enhancements

RepoZ RepoZ is a zero-conf git repository hub with Windows Explorer- & CLI-enhancements. It uses the git repositories on your machine to create an efficient navigation widget and makes sure you’ll never lose track of your work along the way. It’s populating itself as you work with git. It does not get in the way and does not require any user attention to work. RepoZ will not compete with your favourite git clients, so keep them. It’s not about working within a repository: It’s a new way to use all of your repositories to make your daily work easier.

Keyboard shortcut in windows: Ctrl+Alt+R.
Runs as a taskbar application in Windows.

Source: awaescher/RepoZ: A zero-conf git repository hub for Windows and macOS with Windows Explorer- & CLI-enhancements

c# – How to read request body in a asp.net core webapi controller?

 

How to read request body in a asp.net core webapi controller?

A clearer solution, works in ASP.Net Core 2.1 / 3.1

Filter class

using Microsoft.AspNetCore.Authorization;
// For ASP.NET 2.1
using Microsoft.AspNetCore.Http.Internal;
// For ASP.NET 3.1
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Filters;

public class ReadableBodyStreamAttribute : AuthorizeAttribute, IAuthorizationFilter
{
public void OnAuthorization(AuthorizationFilterContext context)
{
// For ASP.NET 2.1
// context.HttpContext.Request.EnableRewind();
// For ASP.NET 3.1
// context.HttpContext.Request.EnableBuffering();
}
}

In an Controller

[HttpPost]
[ReadableBodyStream]
public string SomePostMethod()
{
//Note: if you're late and body has already been read, you may need this next line
//Note2: if "Note" is true and Body was read using StreamReader too, then it may be necessary to set "leaveOpen: true" for that stream.
HttpContext.Request.Body.Seek(0, SeekOrigin.Begin);

using (StreamReader stream = new StreamReader(HttpContext.Request.Body))
{
string body = stream.ReadToEnd();
// body = "param=somevalue&param2=someothervalue"
}
}

 

Source: c# – How to read request body in a asp.net core webapi controller? – Stack Overflow

Solution for .NET error: The type ‘HttpResponseMessage’ exists in both ‘System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ and ‘System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’

Got this error when building a .NET framework (version 4.6.1) solution containing multiple projects:

The type 'HttpResponseMessage' exists in both 'System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

My solution:
Install System.Net.Http version 4.0.0 as nuget package to the “failing project”.

Added this to the “failing” project app.config file:

<assemblyBinding>
<!-- other dependentAssembly bindings here -->
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>

Updated the “failing” projects .csproj file like this:
Removed this line or similar for System.Net.Http:

<!--<Reference Include="System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />-->

Added “hintpath” with projects relative path to the nuget packages.
In my example its 3 level up and then down (..\..\..) you might need to adjust to your projects folderstructure.

<Reference Include="System.Net.Http, Version=4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.Net.Http.4.0.0\ref\dotnet\System.Net.Http.dll</HintPath>
</Reference>

Voila.

Most Complete MSTest Unit Testing Framework Cheat Sheet

using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MSTestUnitTests
{
    // A class that contains MSTest unit tests. (Required)
    [TestClass]
    public class YourUnitTests
    {
        [AssemblyInitialize]
        public static void AssemblyInit(TestContext context)
        {
            // Executes once before the test run. (Optional)
        }
        [ClassInitialize]
        public static void TestFixtureSetup(TestContext context)
        { 
           // Executes once for the test class. (Optional)
        }
      
        [TestInitialize]
        public void Setup()
        {
             // Runs before each test. (Optional)
        }
        [AssemblyCleanup]
        public static void AssemblyCleanup()
        {
           // Executes once after the test run. (Optional)
        }
        
        [ClassCleanup]
        public static void TestFixtureTearDown()
        {
            // Runs once after all tests in this class are executed. (Optional)
            // Not guaranteed that it executes instantly after all tests from the class.
        }
        
        [TestCleanup]
        public void TearDown()
        { 
            // Runs after each test. (Optional)
        }
        // Mark that this is a unit test method. (Required)
        [TestMethod]
        public void YouTestMethod()
        {
           // Your test code goes here.
        }
    }
}

 

Source: Most Complete MSTest Unit Testing Framework Cheat Sheet