Giter Site home page Giter Site logo

Add api exception mode about dsf-python HOT 2 OPEN

duet3d avatar duet3d commented on June 27, 2024
Add api exception mode

from dsf-python.

Comments (2)

mfs12 avatar mfs12 commented on June 27, 2024

This is how a solution could look like for python:

class DsfException(Exception):
    """Base class for all DSF exceptions"""
    def __init__(self, message):
        super().__init__(message)


class InternalServerException(DsfException):
    """Exception returned by the server for an arbitrary problem"""

    def __init__(self):
        super().__init__("Internal Server Exception")


class ErrorResponseException(DsfException):
    """Exception returned if an Error Response is received"""

    def __init__(self, error_type: str, error_message: str):
        super().__init__("{}: {}".format(error_type, error_message))

This is an incomplete overview of found errors

  • NotImplementedError Error: M3: Command is not supported in machine mode FFF
  • NotImplementedError Error: Operation is not supported
  • NotImplementedError Error: M260: I2C not available
  • MissingParameter Error: M42: missing parameter 'P' or Error: M118: missing parameter 'S' or Error: M307: missing parameter 'H' or Error: M581: missing parameter 'T' or Error: M591: missing parameter 'D'
  • OutOfRangeError Error: M593: parameter 'F' too low
  • DeprecationWarning Error: M305: M305 has been replaced by M308 and M950 in RepRapFirmware 3
  • FileNotFoundError Error: M24: Cannot print, because no file is selected!
  • AlreadyStopped Error: M25: Cannot pause print, because no file is being printed!
  • SHA1Error Error: M38: Could not compute SHA1 checksum for file F a l s e: Could not find file '/F a l s e'.
  • FileNotFound Error: M375: Failed to load height map from file heightmap.csv: Could not find file '/opt/dsf/sd/sys/heightmap.csv'.
  • DirectoryNotFound Error: M470: Missing directory name
  • RenamingError Error: M471: Failed to rename file or directory to : Value cannot be null. (Parameter 'input')
  • NetworkError Error: M540: Network-related commands are not supported when using an attached Single Board Computer
  • InvalidStateError Error: M585: a axis has not been homed

from dsf-python.

wilriker avatar wilriker commented on June 27, 2024

Clarification is needed here for go language as well.
Go uses instances of struct error for error handling. You can either return an generic error message by creating it via ```
errors.New("error message")

or create pseudo-static instances like

var ErrSomeDecriptiveName = errors.New("error message")

and then the user can compare against this instance.

AFAIR the Go impl already returns errors where appropriate.

from dsf-python.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.