knit_script.knit_script_exceptions.Knit_Script_Exception module
Module contains knitscript exceptions that are raised when violating knitting specific logic in a knitscript program.
- exception Knit_Script_Exception(message)[source]
Bases:
ExceptionSuperclass for all exceptions related to processing KnitScript programs.
The Knit_Script_Exception class provides the foundation for all error handling in the KnitScript programming language. It extends Python’s built-in Exception class with KnitScript-specific formatting and behavior, ensuring that all KnitScript errors have consistent message formatting and can be caught collectively when needed.
- __init__(message)[source]
Initialize the Knit_Script_Exception.
Creates a new KnitScript exception with the provided error message. The message is automatically formatted with a KnitScript exception prefix and newline formatting for consistent error display.
- Parameters:
message (str | BaseException) – The error message to display. If this is a string, the message will be prefixed with the error class name.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Incompatible_In_Carriage_Pass_Exception(first_instruction, second_instruction)[source]
Bases:
Knit_Script_ExceptionException raised when instructions are combined in a carriage pass that are incompatible.
This exception occurs when two or more instruction types are used together in a single carriage pass but cannot be executed simultaneously due to machine limitations or logical conflicts.
- first_instruction
The first instruction in the incompatible combination.
- Type:
Knitout_Instruction_Type
- second_instruction
The second instruction in the incompatible combination.
- Type:
Knitout_Instruction_Type
- __init__(first_instruction, second_instruction)[source]
Initialize the Incompatible_In_Carriage_Pass_Exception.
- Parameters:
first_instruction (Knitout_Instruction_Type) – The first instruction type in the incompatible combination.
second_instruction (Knitout_Instruction_Type) – The second instruction type in the incompatible combination.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception Required_Direction_Exception(instruction_type)[source]
Bases:
Knit_Script_ExceptionException raised when attempting a carriage pass without specifying a direction for yarn-carrier operations.
This exception occurs when operations that require yarn carriers are attempted without establishing a carriage direction, which is necessary for proper yarn handling and loop formation.
- instruction_type
The instruction type that requires a direction.
- Type:
Knitout_Instruction_Type
- __init__(instruction_type)[source]
Initialize the Required_Direction_Exception.
- Parameters:
instruction_type (Knitout_Instruction_Type) – The instruction type that requires a direction.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception All_Needle_Operation_Exception(first_needle, second_needle, racking, instruction)[source]
Bases:
Knit_Script_ExceptionException raised when an all-needle operation occurs without an all-needle racking.
This exception occurs when operations that require all needles to be properly aligned (such as certain transfer operations) are attempted when the machine racking is not set to an all-needle position.
- first_needle
The first needle in the operation.
- Type:
Needle
- second_needle
The second needle in the operation.
- Type:
Needle
- instruction
The instruction type being attempted.
- Type:
Knitout_Instruction_Type
- __init__(first_needle, second_needle, racking, instruction)[source]
Initialize the All_Needle_Operation_Exception.
- Parameters:
first_needle (Needle) – The first needle in the operation.
second_needle (Needle) – The second needle in the operation.
racking (int) – The current racking value.
instruction (Knitout_Instruction_Type) – The instruction type being attempted.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception No_Declared_Carrier_Exception[source]
Bases:
Knit_Script_ExceptionException raised when no working carrier has been declared for operations that require one.
This exception occurs when knitting or tucking operations are attempted without first declaring a working yarn carrier, which is necessary for these operations to form proper loops.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.