skip to Main Content

Asp.net – Flexible way to handle exception in Web API

I'm currently making a web API with .NET 6. The code bellow is my Exception handler class: public class ExceptionsMiddleware { private readonly RequestDelegate requestDelegate; private readonly ILogger<ExceptionsMiddleware> logger; public ExceptionsMiddleware(RequestDelegate requestDelegate, ILogger<ExceptionsMiddleware> logger) { this.requestDelegate = requestDelegate; this.logger =…

VIEW QUESTION

Flutter – Why I can't check if `response.body` is null or not?

I am trying to see if a username already exist in the database or not, using the following code: Future<bool> checkUsername(userName) async { try { final response = await http.post( Uri.parse('http://10.0.2.2:3000/username'), headers: {'Content-Type': 'application/json'}, body: json.encode({'user_name': userName}), ); print('response ${response.body}');…

VIEW QUESTION

Why does json.NET give “Additional text encountered after finished reading JSON content”?

I'm trying to deserialize a JSON object. The value of the string 'plaintext' is: {"expiryDay":1,"expiryMonth":6,"expiryYear":2023,"machineGuid":"a3586fb9-b05e-46f1-a4a0-683a97109e34","name":"Alexander Farley"} This line throws an exception: var json = JObject.Parse(plaintext); The exception is: Newtonsoft.Json.JsonReaderException: 'Additional text encountered after finished reading JSON content: . Path '',…

VIEW QUESTION

Null check operator used on a null value Cast Error Flutter

Receiving this error _CastError (Null check operator used on a null value), tried replacing ! with ? but that doesn't work. Please help me fix this issue, Thanks. home_screen.dart import 'package:flutter/material.dart'; import 'package:mvvm/data/response/status.dart'; import 'package:mvvm/model/movies_model.dart'; import 'package:mvvm/utils/routes/routes_names.dart'; import 'package:mvvm/view_model/home_view_model.dart'; import…

VIEW QUESTION
Back To Top
Search