
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to declare custom exceptions in modern Python?
To override something or pass extra arguments to the exception we do like this in modern python:
class ValidationError(Exception): def __init__(self, message, errors): super(ValidationError, self).__init__(message) self.errors = errors
That way we could pass dictionary of error messages to the second parameter, and get to it later on when needed.
- Related Questions & Answers
- How to define custom JavaScript exceptions?
- How to use Custom Exceptions in JavaScript?
- Custom exceptions in Java
- What are custom exceptions in Java?
- How to write custom Python Exceptions with Error Codes and Error Messages?
- What are the custom exceptions in C#?
- User defined and custom exceptions in Java
- How can I add condition in custom exceptions in java?
- How to declare a variable in Python?
- Concrete Exceptions in Python
- How to design a modern Website?
- Modern Microprocessors
- How to declare a global variable in Python?
- How to implement a custom Python Exception with custom message?
- Raising an Exceptions in Python
Advertisements