-1

when i search this on google then it show that error means compile time error and exception is runtime error? but i think that it is not that so....

  • 1
    Error is a situation which cannot be fixed and can be reported only. Exception is not an error, this is special situation which must be handled. – Akina Feb 02 '22 at 05:23
  • This concept of Error vs Exception is not specific to databases, it it one of the fundamental paradigms of writing code, either the code can be interpreted or it is an `Error`, interpreted or _compiled_ code can raise `Exceptions` at runtime. In MySQL (and other RDBMS) there is a _type_ of Exception called an `Error Exception` and that just further confuses the terminology... – Chris Schaller Feb 02 '22 at 05:30
  • https://dev.mysql.com/doc/connector-python/en/connector-python-api-errors-error.html#:~:text=Initializing%20the%20exception%20supports%20a%20few%20optional%20arguments%2C,used%20by%20%20your%20application%20to%20raise%20exceptions. – Chris Schaller Feb 02 '22 at 05:31
  • 1
    "_If a condition is raised that causes a statement to have no effect other than that associated with raising the condition (that is, not a completion condition), then the condition is said to be an exception condition or exception. If a condition is raised that permits a statement to have an effect other than that associated with raising the condition (corresponding to an SQLSTATE class code of successful completion, warning, or no data), then the condition is said to be a completion condition._" ISO/ANSI SQL standard. I.e. an error is an exception. – jarlh Feb 02 '22 at 07:55

2 Answers2

1

That is generally correct. Although the terms are colloquially interchangeable in many domains.

An Error, also known as a compile-time error, is a statement of fact. (Or NOT fact) The compiler is unable to compile the output.

  • Technically an error is a state in code that has raised an exception in the compiler's runtime :)

An Exception is raised at runtime and is the result of an exceptional combination of values.

Because an Exception is raised at runtime, we can generally write code to catch and handle or workaround an exception within your script or code. An Error prevents the code from being compiled and thus executed at all, so our only option is to modify the code to resolve an Error.

A compiler may perform syntax and sometimes type checking to ensure that the code follows a set of pre-determined rules and can be compiled into executable statements, but it is not until invalid values are passed into those statements that an Exception can occur, that is harder for a compiler to do and so is generally only detected at Runtime.

Some advanced or specialised compilers may perform checks against common values and as a programer you can write unit tests to try and pre-emptively detect exceptions before releasing your code.

Chris Schaller
  • 13,704
  • 3
  • 43
  • 81
0

Exceptions and Errors are the same things. Somewhere in software history, someone came up with the phrase “Exceptions are exceptional”. That sounds catchy but it doesn’t translate to Exceptions and Errors. If you go that route then who decides what is Exceptional? It is very subjective an error for one context could be exceptional to one and not to another. Exceptional and Exception are very different words. Someone apparently thought the catchy phrase enforces the idea that there is a difference.

They are the same thing. I’m not a Java developer and I realize it has different classes for each but in the .NET world they are the same thing. The preferred error handling framework in .NET is the Exception class. It doesn’t care what you want to call it, an error or an exception. Nor does it care if it is exceptional or not. It is just a vehicle for communicating error information. You can communicate the severity of an error by creating and using classes that inherit from Exception.

The Source of my information is here:

Cwalina, K., Abrams, B. F., Barton, J., Icaza, M. de, & Hejlsberg, A. (2020). Framework design guidelines: Conventions, idioms, and patterns for reusable .net libraries. Addison-Wesley.