marjan.nikolovski down the rabbit hole error handling examined-v01

25
Ready Marjan Nikolovski Father, Dev, CEO/Emit Knowledge Down the rabbit hole Error handling examined try { } // Twitter: @m4rjann // Blog: emitknowledge.com/research- labs

Upload: marjan-nikolovski

Post on 16-Apr-2017

324 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Marjan NikolovskiFather, Dev, CEO/Emit Knowledge

Down the rabbit holeError handling examined

try {

}

// Twitter: @m4rjann// Blog: emitknowledge.com/research-labs

Page 2: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Page 3: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Agenda

• Error theory;• Error types;• Handling error per type;• Responsible sides;• Error handling strategies;• Error handling for business logic;• Error handling for client;• Error handling for web applications;• Log analytics;

Page 4: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

ERROR IS AN ANY INTERUPTION THAT STOPS THE SYSTEM TO EXECUTE A BUSINESS CONTEXT

Page 5: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

A system must have a good strategy when it comes to error handling

Most of the code in a solution is trying to handle different types of errors and exceptions

It is easy to specify and write code to make the system operable. Hard times come when trying to predict what can go wrong

Page 6: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Bugs, issues we can’t predict nor control. Ex: Stackoverflow, Nullpointer...

Error types

using System;

class Program{ static void Main() {

User appUser = DomainServices.User.GetByUsername(@“marjann”);

Console.WriteLine(appUser.Email); }}

Page 7: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Error from invalid input.Ex: We expect integer value, the user enters some random characters...

Error types

using System;

class Program{ static void Main() {

var userIdInput = Console.ReadLine();int id = int.Parse(userIdInput);Console.WriteLine(id);

}}

Page 8: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Infrastructural problems.Ex: Missing write permissions on server, full disk, DB not available...

Error types

using System;

class Program{ static void Main() {

var user = UserRepository.GetByUsername(@”marjann”);Console.WriteLine(user.Email);

}}

Page 9: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Bugs are system problems that we can’t handle unless we apply a patch.

So what types of errors we can handle?

Invalid data entry is a system problem that we can handle proactively.

If we have infrastructural problems, the system should be able to notify the system administrators.

Page 10: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

End clients who are using the system.

Responsible sides

System administrators.

Software developers.

Page 11: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Software developers.

Who should handle the bugs?

Page 12: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Global – architectural decision on system level.

Error handling strategies

Local-contextual – handling errors in a process/method/action.

Page 13: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

КЛИЕНТ/КОРИСНИЧКИ ИНТЕРФЕЈС

БИЗНИС ЛОГИКА

ПОДАТОЧНО РЕПОЗИТОРИ

АПИ СЕРВИСИ

ЕКСТЕРНИ СЕРВИСИ

СПРАВУВАЊЕ СО ГРЕШКИ

ERROR HANDLING

Web/Mobile/Device REST API SERVICES

BUSINESS LOGIC

DATA REPOSITORY EXTERNAL SERVICES

Page 14: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Global perspective of the system.

GLOBAL STRATEGY

Centralized error handling.

We want detailed error instead of wrapped exception.

We want execution details.

We want unified error messages.

Page 15: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

GLOBAL STRATEGY

Internally, a system should not hide the exceptions.Ex: User.IsExistingUsername(“marjann”) -> DbConnetionException != false

Externally, a system should always be transparent and should support unified error information when an error occurs.Ex: Invalid username, Username is not valid!?

Page 16: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Say hello to the local context.

What if we can retry?

Use local context as an exception to the rule!

We can’t predict and handle all of the errors, but we must keep the system alive.

Exception to the rule: If it does not work fake it!

Page 17: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Unification of errors, codes and groups.

Error handling for business logic

Information about an error(Error Info) against Exceptions.

Enrich an error with data for logging aspect.

Page 18: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Demo

Page 19: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Be transparent and show enough information to the end user.

Error handling for client

Page 20: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Demo

Page 21: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Error message localization.

Error handling for web applications

Transferring error information back to the app.

Page 22: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Demo

Page 23: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Who, What, How, Where, When?

Log analytics

PROM – tool for process mining.

We should be able to answer:- How our system is used?- Where our system perform slow?- Parameters of execution?- Patterns of execution?

Page 24: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

Page 25: Marjan.nikolovski down the rabbit hole   error handling examined-v01

Ready

catch(PPTException up){

}

Logger.Log(“QUESTIONS?”, up);throw up;